Apply a rotation AND a torque at the same time ?

Hi, I have an issue since a while now.

My player have a rigidbody. I’m making him lookaround with the mouse and transform.Rotate(). And in my game there is an event that apply a torque with rigidbody.addTorque that make the player rotate. In the editor updates and fixedUpdates are synchronized and both can be applied at the same time, works fine.

But when I build, Updates are way faster than fixedUpdates. So when I try to apply both at the same time the transform.Rotate() ‘overwrite’ the addTorque. I tried a coroutine ‘waitForFixedUpdate’ for the Rotate(), now both work at the same time in the build, but when I look around with the Rotate() it’s jittering, not smooth at all. Anyone could help me please?

@Tritize, It’s not exactly clear in your post but If you are using Righdbody Physics do not also attempt to manipulate the transform properties of the object

Note that all input code must go into an Update event handler to work properly and always use FixedUpdate for physics related code for it to work properly.

You may Use and of Rigidbody rotation methods to try to rotate an object to look at something

Another way is add your object as a child of the Rigidbody - that is, apply a Rigidbody to the an empty game object and give it a collider. Remove the Rigidbody and collider from your game object and add it as a child of the empty parent Rigidbody object. You can then freely and rotate child transform without any conflict.

You can try to synchronize Update and FixedUpdate, but you have to be aware of how much your code is trying to do with physics. I recommend reading this article: Fix your (Unity) Timestep! — John Austin