- Home /
Can I limit the maximum acceleration applied by addTorque?
I'm working on a flying game, using a rigidbody to control the craft.
I use this code for yaw:
m_body.AddTorque(myTransform.up * Input.GetAxisRaw("Mouse X") * torque, ForceMode.Acceleration);
and this for roll:
m_body.AddTorque(-myTransform.forward * Input.GetAxisRaw("Horizontal") * rollPower * Time.deltaTime, ForceMode.Acceleration);
Because the mouse input gives a value depending on how fast you move the mouse, it will apply higher torque values than with keyboard. I can limit the max turning speed with maxAngularVelocity, but that won't affect how quickly you can reach the max turning speed with the mouse.
I could use mathf.clamp to limit the value that mouse gives, but then it makes it framerate dependant, because you can reach the limit with a slower mouse movement speed on lower framerates.
Any ideas? Maybe if I scale the mouse sensitivity based on time.deltatime? Can that be done?
Your answer
Follow this Question
Related Questions
How to properly convert mouse pos to world pos 1 Answer
newbie: drag a rigidbody with mouse 2 Answers
How to have a cube to fall on fixed rotation? 1 Answer
Top Down car/vehicle movement 1 Answer
Torque never goes down? 1 Answer