Search Unity

Velocity keeps increasing even after wheelcollider.motortorque is set to zero

Discussion in 'Physics' started by mark0191, Mar 23, 2015.

  1. mark0191

    mark0191

    Joined:
    Mar 23, 2015
    Posts:
    3
    I am currently working on a racing game and I am running into an issue. Currently if I press the forward key all the wheels get a motortorque. But if I release the key after a few seconds then the velocity will keep increasing. How can I make it stop increasing after I release the key?

    Current code:
     
  2. Roni92

    Roni92

    Joined:
    Nov 29, 2013
    Posts:
    225
    Check whats your axis values are, then check motorTorque values on some wheel. MotorTorque needs to be zero to stop accelerating. Also linq expression in fixedUpdate is not efficent(not good) solution.
     
  3. mark0191

    mark0191

    Joined:
    Mar 23, 2015
    Posts:
    3
    The axis values and motortorque do get set to zero
     
  4. BTables

    BTables

    Joined:
    Jan 18, 2014
    Posts:
    61
    I have a theory on this one, it could be due to the angular velocity of the wheel as it has a mass of its own. Especially if you are using unity5, where to get any decent forward force you need an absurd amount of torque causing your wheels to be moving stupidly fast.

    What I suspect is happening is that the wheel is spinning much faster than the vehicle is moving but not getting traction (like a burnout), after you stop applying torque, the wheel should come back into traction and transfer its momentum to the car, this doesn't happen because your slip curve doesn't cut off fast enough (really hard to get it to do that in unit5)

    Im not sure if these concepts are even simulated, it would make sense tho

    Try reducing the mass of the wheel and see if it helps
     
  5. mark0191

    mark0191

    Joined:
    Mar 23, 2015
    Posts:
    3
    Ah thank you, reducing the mass to 0.1 reduced the problem to it being barely noticealbe. It will do for me.
     
    mustafahtp3 likes this.
  6. IToastPotatoes

    IToastPotatoes

    Joined:
    Feb 21, 2020
    Posts:
    1
    This is literally 5 years old but im just commenting to say that you sir are a F***ing genius and have literally fixed my game. Increasing the traction of the wheels has made the drifting incredible and fixed the issue with the car moving when it shouldnt be. Thank you very much.
     
    mustafahtp3 likes this.
  7. lucas_hehe2011

    lucas_hehe2011

    Joined:
    Dec 21, 2020
    Posts:
    1
    Thank you so much, I would never have thought of that.