Search Unity

[Solved]Car Clutch Implementation Problem

Discussion in 'Physics' started by NDSno1, Sep 29, 2016.

  1. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    195
    Hi all,

    I'm developing a racing game and is using WheelCollider. I'm trying to implement a clutch that uses the triggers on the Xbox 360 controller. However, based on my equation, I'm having problem:
    WheelCollider.motorTorque = EngineTorque * GearRatio * FinalDrive * ClutchInput
    Since the ClutchInput will be 0 when the trigger is not pressed, the torque to wheel will be zero, which is not what I want. I want the clutch to be 1 when not pressed, and when fully pressed it will be 0, which means the torque from engine will not be transferred to the wheel, and that's what a real car is like.
    If I change ClutchInput to 1/ClutchInput, I'll have division by 0 exception.
    Also before this function, I have other functions that calculate the EngineTorque separately from the WheelCollider.motorTorque and independent from the WheelCollider, so I think it would be best to have the ClutchInput involves in this step.
    Is there a way to change that function somehow to meet the requirement, or I should use some other scripting tricks?
     
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,061
    WheelCollider.motorTorque = EngineTorque * GearRatio * FinalDrive * (1.0f - ClutchInput);
     
    NDSno1 likes this.
  3. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    195
    Oh my goodness why I couldn't I think of this earlier.
    Thanks so much