Animation while collision

Hello.

I have 2 characters - hero and enemy (zombie).
They are animated, they can walk bla bla…
I want my zombie to punch the hero (play punch animation) when the hero is close to the enemy (collision box). When hero will go away I want my zombie go back to normal walking.
Any tips for that? Any tutorial videos for triggered character animations between two characters?

Thx for help.

There are differrent ways to accomplish this and collision is one of them but maybe a bit more reliable is to do a distance check between enemy and player. You can do this every half second or whatver, it doesn’t have to be a per frame sort of thing. So as soon as you are within range, start the attack and out of range, stop the attack.

Your setup could be a timer running in a loop, doing a distance check. Using a branch you can compare the current distance with a target distance, say 200 or whatever. As soon as current distance is less than 200 set your attack boolean to true. If it’s more than 200 set it to false. You can read that boolean value for your animation blueprint to activate the correct animation. Or if you are using montage, you can play or stop the attack animation based on the distance in stead of setting a boolean.

If you specifically wanted to use collision, then your setup will be very similar accept you’ll use OnOverlap and EndOverlap to set your boolean or call your montage. The reason I’d use distance is because it’s pretty much 100% reliable where collision could possibly fail, and if that happens, your animation does not start or stop. If it doesn’t start, it could possibly be acceptable, if it’s rare, but if it does not stop, it’s not good at all. You can test it out and you’ll see what works for you as you play test. Unforseen stuff pops up all the time during play testing.

Hope that makes sense. That’s the basic idea anyway… :slight_smile:

I am sorry, I am a noob, so all of these instructions sound quite straight forward and simple, I just wander if the original person who posted the question has accomplished this or if anyone has blue prints of this, it would be very helpful to use them to understand

It’s absolutely possible and used to be a good practice to code everything independent of physics simulations.
Nowadays people use PhysX even for small things such as match3 games btw…

I wouldn’t use physics for this stuff; I’d make a system based on animation notifies instead.