Game Creation Mastering Development

rotate rigidbody in one direction with AddTorque

I can’t understand how to rotate an object with AddTorque in the direction the camera is pointing. I tried to compare the rotation of the camera with that of the object. The result is that the object rotates only for a certain range in the same direction as the camera, after which it rotates in unequal directions.
How can I fix it?

var currentR = rb.rotation.y;
var targetR = Camera.main.transform.rotation.y;
rb.AddTorque(transform.up * 1000f * (targetR - currentR));

Leave a Reply

Your email address will not be published. Required fields are marked *