Keeping a rigidbody character upright, without constraining, grounded or otherwise, with slopes?

I have searched and searched for a solution, found many people looking for what seemed to be the same thing, but try as I might the solutions I found fell short.
Once I got my character to get back upright relative to its individual offsets, but not in any sort of update function.
Once, I got my character staying upright, but it going past my limits would reset it on all axis.

I have a character, that I was moving with a vector3 fetched from an on-screen joystick, seeking SM64-like controls.
I badly want my character to align to the terrain it is standing on.
I found some convoluted solutions involving raycasting, but what I think I’d rather work with is a physics based character, and somehow clamp how far it can rotate on the X and Z axis, with physics.
83796-picc.png

Desired result:

As you can see, I don’t want to constrain the rigidbody, because I actually need it to rotate on all axis.
I just want to limit, or clamp, how far the character can rotate, so that if it were to climb a slope, my character would lean with the slope ( i drew an armless stick figure to show what I mean, but my actual character is a rabbit which is on all fours, so my capsule collider is on the Z axis).

Here’s a little code I had in my LateUpdate, derivative from something I found on an old forum post.

		if (transform.localRotation.eulerAngles.z > 0.25f) {

			transform.localRotation = Quaternion.Euler(transform.localRotation.x, transform.localRotation.y, 0.25f);

		}

		if (transform.localRotation.eulerAngles.x > 0.25f) {

			transform.localRotation = Quaternion.Euler(0.25f, transform.localRotation.y, transform.localRotation.z);
		}

However, this would just seem to lock my rotation to world-relative one, where I was still moving forward and back relative to my own rotation, but snapped onto one axis. Debug logs would show the limit triggering, no console errors, but my character would keep on turning and topple over.

Any resources would help, a push in the right direction, or a tutorial that accomplishes this (I have yet to find one).

This is what you need:

this.gameObject.transform.rotation = Quaternion.Euler(0, this.gameObject.transform.rotation.y, this.gameObject.transform.rotation.z);

That way the X rotation will always be the same and won’t tip over. You can change the 0 to whatever angle you need to keep.

Also, the image you posted doesn’t work (for obvious reasons).