- Home /
Can you explain me please in more details what is motorTorque?
I'm begginer with unity, and i want to know what is motorTorque propriety from WheelCollider class. I have the following code: var maxTorque : float = 50; function Update() { WheelCollider.motorTorque = maxTorque * Input.GetAxis("Vertical"); }
Please explain me what motorTorque is and how it's work:)
Answer by c.rajiv.chandel · Aug 21, 2013 at 01:20 PM
This is value of force around wheel axis which make your wheel spin around this axis, bigger the value of motorTorque causes more rotation for longer period in front direction. And try to avoid using negative torque tough.
Ok... so in my case the wheel will spin around it's axis 50 times/frame? Please help me, i really can't understand. and thank you for the replay:)
Let me try to explain you lit bit in more detail:
var wheel : WheelCollider;
var $$anonymous$$OTOR_$$anonymous$$AX = 10;
private var motor = 0;
function FixedUpdate () {
motor = $$anonymous$$athf.Clamp(Input.GetAxis("Vertical"), 0, 1);
wheel.motorTorque = $$anonymous$$OTOR_$$anonymous$$AX * motor;
}
The FixedUpdate function is the most important part of script. The FixedUpdate function is run once every frame that the physics of the scene is updated.
In the function I grab the user input for motor. you can use W and S keys for input. Input.GetAxis(“Vertical”) gets W and S key presses. In this case you can use W to apply the accelerator and S to apply the brake. So we have clamped, or restricted, the vertical input returns so I know when they are positive (the W key, going forward) and negative (the S key, going backward or braking).
With the user input given on motor. you can then apply those to the wheel colliders. The motor torques are applied to wheel. motorTorque is property of the Unity wheel collider. This is how we can use this. hope this answers your question.
$$anonymous$$uch better..... thank you so much! You make my day!:)
my pleasure, if my answer is acceptable to you then you can accept it as answer of your question, if you have some time.
Your answer
Follow this Question
Related Questions
Can I emulate simple space-like gravity? 2 Answers
Unity3d fails when uses float value. 1 Answer
I dont want Decimals :P 1 Answer
Shooting. Bullet floats and sprays 1 Answer