- Home /
Adding More Torque
How is it possible to add more torque to an object in short bursts, increasing the value does nothing and changing the max angular velocity doesn't work either. I've already increased the max angular velocity but what I need is for when the player presses a button they'll move faster, as I've already stated trying to increase the max angular velocity in code doesn't work and you would have to speed up other objects' angular velocity. I'm just asking for an explanation, not code or anything.
If there is no way this can be done, can I somehow fake it. If I use addForce it produces a unrealistic effect, I don't know what to do.
Is it really necessary to use physics? Otherwise I could give you some pseudo-code on how to write your own rotation code.
That way you have full control over the rotation and its speed.
I want the character to be completely physics based along with most other things in the game.
torque needs to build up to work, one instance for one frame only won't 'twist' the character. in a new scene, create a cube with rigidbody and mass 1. add the following script to the cube. then create another larger cube for the floor, add rigidbody and set to is kinematic - true :
public var turnForce : float = 1000.0;
private var moveX : float = 0.0;
function FixedUpdate()
{
moveX = Input.GetAxis ("Horizontal");
rigidbody.AddTorque( Vector3.up * moveX * turnForce * Time.deltaTime );
}
Answer by Tim-Michels · Jun 22, 2012 at 06:29 AM
Well, you're right about the maximum angular velocity. You should definately raise that value if you want stuff to rotate faster.
The next important thing you should know it the way you apply the force. When you use AddTorque, this is indeed a force that needs to build up, but you can also pass a ForceMode parameter.
You should test some stuff with:
rigidbody.AddTorque(100, 0, 0, ForceMode.Impulse);
When you're only applying the torque once, and not every frame, you don't have to take Time.deltaTime in account, because the framerate doesn't matter for an impulse force.
Cheers