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;
}
}
}