I have a door in my game and if you spam interact with it while it is animating, you can break it and make it change the original close and open positions.
I figured the best way to resolve this would be to detect when it’s animating and stop the player from interacting with it while “animatingOpen/animatingClose = true”, but I’m not certain how to detect this in the script
Thanks!
There are 2 scenarios you can have,
1st one,
You might want player to not able to walk through doors until it has stopped animating.
2nd
You might want player to ignore door and pass through it any way, which means, door is not exist.
I will answer for first case.
add bool variable in the door script and set it default to false;
isAnimating = false;
Whenever you start animating your door, set this bool to false. Once animation is completed, set it true again.
Add second collider which will be enabled when door is animating. This collider will not allow player or other character to come closer to the door when it’s animating.
When you set it false, disable the trigger that invoke player interaction with the door and enable another collider which will prevent player from coming to door while it is animating.
When you set it true enable the trigger and disable the second collider.
I hope this will help.