How to make a one way trigger?

In my game, there is a cat that jumps on pillars. When it lands on a pillar, force is applied and it jumps. There are three animation states which are just single image. The states are : idle,up and down.

When cat lands on the pillar, Collision is triggered where i set animation state to idle. Then, force is added and animation state is changed to up. But problem is, this collision and add force happens so fast, the cat switches between down and up without showing idle.

To overcome this, i added an empty child object to pillar. Then added Edge collider set as trigger. This child was placed slightly above the pillar. So when cat hit this, animation state would switch to idle. Then the cat would land on pillar and jump.

This worked except, the trigger is two way. When cat jumps from pillar, it collides with this trigger and state is changed from up to idle. I tried to add platform effector with one way, but the effector cannot be used on a trigger.

So, is there a way i can add a collider to the empty child which will let it go through aftyer setting state to idle?

• Rather than a 1-way trigger (which is possible in script), you might prefer to solve this by modifying your animation control - whether it's an Animator state machine or a behaviour script. This keeps better separation of concerns: the animation scripts handle the visual changes, and the triggers in the world represent gameplay & physics interactions. Adding gameplay triggers to every pillar to fix an animation glitch will work, but it's messy compared to fixing the issue at its source. – DMGregory May 24 '15 at 14:22

1 Answer

If you have trouble getting a good blend in between your animation states you could break it up using Invoke() within your OnTriggerEnter(). I don't normally like to do this but it will most likely solve your state issue and give it time enough to show the idle before your jump.

Invoke("PillarAddForceMethod", .6f);

void PillarAddForceMethod()
{
//ToDo : ADD FORCE
}