How do i keep a rigidbody upright? Looking for best way to freeze rotation

I am working on a making a ridable horse and trying to figure out how to keep the rigidbody upright by not rotating the z axis. I have gone through so many posts and videos looking for an answer but seems like so many different solutions, many of which suggest using transform.rotation and setting euler angles to 0 or something like that, and I am looking for one that’s more efficient and reliable, avoiding gimbal lock and just rotating the rigidbody directly. This kind of got it working in FixedUpdate and keeping it from falling over sideways, but the movement becomes choppy and bouncing around a bit. I feel like this must be a very common issue but doesn’t seem to be a common solution. Thanks for any help!

Quaternion rotationUpright = Quaternion.LookRotation(rbMount.transform.forward, Vector3.up);
rbMount.rotation = rotationUpright;

As noted by the docs;

Note that [Rigidbody] position constraints are applied in World space, and rotation constraints are applied in Local space.

This means that if you want to freeze rotation around the local z-axis, you can just constrain that axes’ rotation (either through script, or through the editor). Aside from that, you could do the above but instead of directly setting the rotation use the MoveRotation method;

Quaternion rotationUpright = Quaternion.LookRotation(rbMount.transform.forward, Vector3.up);
GetComponent<Rigidbody>().MoveRotation (rotationUpright);

This will do the same thing, but the rotation will be run through the physics simulation, so it should be much smoother.