- Home /
Torque applied only after force
Trying to control a cube/rigidbody by applying forces to it.
While the forces are applied correctly, torque (used to rotate) won't apply when the cube is still.
It applies only when the cube is already moving (with AddForce).
Any idea as to what causes this?
The terrain uses the standard Ice physic matterial and the cube has 0 drag/angular drag.
Thanks in advance!
public class MovementScript : MonoBehaviour {
public float speed = 3000.0f;
public float rotationSpeed = 300.0f;
void FixedUpdate ()
{
float verticalMovement = Input.GetAxis ("Vertical");
float horizontalMovement = Input.GetAxis ("Horizontal");
Vector3 movement = new Vector3 (0.0f, 0.0f, verticalMovement);
Vector3 rotate = new Vector3 (0.0f,horizontalMovement, 0.0f);
rigidbody.AddTorque (rotate * rotationSpeed *Time.deltaTime);
rigidbody.AddRelativeForce (movement * speed * Time.deltaTime);
}
}
Comment