Hello, i’m using .AddRelativeTorque to rotate on Pitch and Yaw axis ( x and y ) but i don’t understand why and how a rotation is only applicated on the roll axis ( z ) ?
mouse_h = Input.GetAxis("Mouse X") * sensivity;
mouse_v = Input.GetAxis("Mouse Y") * sensivity ;
rb.AddRelativeTorque(Vector3.forward * mouse_h);
rb.AddRelativeTorque(Vector3.right * mouse_v);
Vector3.forward is the roll axis (+z). If you want yaw, you should rotate around Vector3.up(+y). Vector3.right(+x) is the pitch axis.
oh, i haven’t noticed that ! But it still don’t work…
Try to use the local axis of your object:
rb.AddRelativeTorque(rb.transform.up * mouse_h);
rb.AddRelativeTorque(rb.transform.right * mouse_v);
I don’t think that’s correct. https://docs.unity3d.com/ScriptReference/Rigidbody.AddRelativeTorque.html AddRelativeTorque already uses the local coordinate system of the body. The example in the manual even uses Vector3.up.
@Saint-Pasteque what is currently happening with your code that is different from what you expect?
Right but that’s AddTorque, and we’re talking about AddRelativeTorque.