I try to rotate a rigidbody. Rotation for slow speeds work just fine, but if i want to rotate faster a have a problem, that Quaternions only work from 0-360°, but if I like to use a speed that needs 2 or 3 rotation per calculation it does not work in right way.
Here is my code:
var anglePerSecond = Controller.SpeedInMs * 360.0f / (2.0f * this.transform.localScale.x * (float)Math.PI);
var q = Quaternion.Euler(0.0f, -anglePerSecond * Time.deltaTime, 0.0f);
rigidbody.MoveRotation(rigidbody.rotation * q);
Thanks for helping
Ugly problem, and I cannot think of a fix. You'll run into issues any time your frame-to-frame rotation is greater than 180 degrees. Assuming you are calculating this in FixedUpdate(), one way to mitigate the issue would be to decrease the FixedTimestep. This will increase the load placed on your game by the physics engine, but reduce the chance of a frame-to-frame rotation greater than 180 degrees.
– robertbu