I’m trying to get a cube to move along the z axis like a sliding door when activated by a trigger. At first I was thinking about doing it by having a “Do” loop in the OnTriggerEnter function, however it just crashed Unity. Please could someone help me out here, there’s probably a simple way of doing this however I’m stumped for the moment.
OnTriggerEnter happend when something triggers your collider. You cant use do/while loop to do animation in there. It represents one frame. Easiest way:
Have a variable that says wheather door should open or close;
bool isOpening = false;
bool stateOpen = false;
When user collides, save the state. Door is now oppening!