I have a transform with a rigidbody attached. I want to rotate this rigidbody based on Mouse X. I figured it would be best to add a GameObject like a cylinder with NO rigidbody and then attach the MouseLook component to it. Then When this transform rotates I want the rigidbody to rotate to the exact same place and stop.
Well, it turns out that this is a lot harder than I expected. I can do this pretty easily with 2 transforms and no rigidbody but the addition of the rigidbody makes this ridiculously difficult. This rigidbody is attached to another rigidbody with a configurable joint (which acts more like a rubber band than a joint).
I’m using this code with undesirable results:
var q = Quaternion.LookRotation(myTransform.eulerAngles);
var str = Mathf.Min (speed * Time.fixedDeltaTime, 1);
rigidbody.MoveRotation(Quaternion.Slerp(rigidbody.rotation, q, str));
I’ve tried many many many variations of this as well.