Stop animation on collision? Barricading doors? Help!

I have doors that open when you trigger the door, but I want the animation to stop working if the door is barricaded on the other side for example: if I would drag a closet infront of the door i don’t want people on the other side to be able to open the door, but when Someone is on the other side the door goes through the object, so I want the animation to stop midanimation when colliding and go back to its idle state. (this way it won’t cause buggy clipping) if this isn’t possible an alternative would be to have an object bigger than a certain trigger (so a dropped gun won’t work) be put inside the trigger and when its inside the animations don’t work anymore till that object is away from the trigger (ofcourse there should be an exception for players)

You could have objects tagged as ‘door blockers’ or something and put colliders under the door objects. The code might look something like:
void OnTriggerEnter(Collider other) {
if (other.tag == “doorBlocker”) {
ourAnimatorComponent.SetTrigger(“goToIdle”);
}
}
In researching an answer for you, I realize there isn’t much of an easy way to pause things in mecanim. So here I’m suggesting that you set up maybe a long trigger to go from this animation to the idle to slowly allow it to transition into idle and settle into closed position.

This isn’t ideal I don’t think… but maybe could help.

1 Like

What if there would be a script that when colliding with the doortrigger itself it will disable the 2 animations on that specific door would that be possible? so instead of idle mode it wont animate at all. Btw thanks for your reaction!

EDIT: what if when a collider of a certain object collides with a trigger the following happens to the trigger: mesh renderer will be disabled block collider will be disabled and the is a trigger is unchecked, the moment the object is out of the collider box it would be enabled again. < Although I have no idea how this would be done