Is there a way to add rotation constraints on a character controller?

I have a cylinder object that rotates 360 degrees on the y asis on a loop. It has a rigidbody attached along with a collider with trigger on, and basic OnTriggerEnter code. If the player stands on top of the cylinder as its rotating, once the circle turns enough and the player is out of room to stand, they should fall off while standing upright.

But currently, my player will match the cylinders rotation and collide with the ground while flat on the ground, then bug out because the player is trying to go through the map.

Is there any way to add a constraint to x & z rotations?

public class RotateCircle : MonoBehaviour
{

    public GameObject Player;
    public Vector3 RotateAmount;
    public float speed = 2.0f;

    void Update()
    {
        transform.Rotate(RotateAmount * speed * Time.deltaTime);
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == Player)
        {
            Player.transform.parent = transform;
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject == Player)
        {
            Player.transform.parent = null;
        }
    }
}

Is your character moved by a rigidbody or Unity’s CharacterController component?

Rigidbody components have settings you can adjust to lock their rotation. However currently you aren’t rotating your cylinder via physics. It should be rotated with Rigidbody.MoveRotation() in FixedUpdate instead. That way the cylinder will properly exert forces on the player’s ridigbody without you having to worry about manual parenting.

The CharacterController component should always remain upright as far as I know. You can simply check it’s .isGrounded property to determine whether it should remain parented.