Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

[Solved]Car Clutch Implementation Problem

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

  1. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    223
    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,689
    WheelCollider.motorTorque = EngineTorque * GearRatio * FinalDrive * (1.0f - ClutchInput);
     
    NDSno1 likes this.
  3. NDSno1

    NDSno1

    Joined:
    Dec 20, 2014
    Posts:
    223
    Oh my goodness why I couldn't I think of this earlier.
    Thanks so much
     
    pauloaguiar likes this.
  4. narlankaaditya

    narlankaaditya

    Joined:
    Sep 23, 2020
    Posts:
    4
    Hey bro can u pls tell how did u calculate the engine rpm separately from wheelcollider. Motortorque? Pls tell how to do this
     
    pauloaguiar likes this.