scripting a hit to an enemy.. an idea how to do it?

Hi…

Have you played Mario 64, Zelda or even any fighting aventure game?..
when you punch an enemy, i have no idea how to do that (scripting), but i can imagine how could it be…

  1. i´m thinking on Animation Events…
    for instance, punch animation has 30 frames, punch hit instant is at frame 20 i could add an animation event that trigger a function in that frame…

or

  1. add an empty box trigger to the player´s fist so then, when it approaches to the body of the enemy, the enemy´s body will act on OnTriggerEnter, if that “other” is a punch, then call a function…

do you have another way to do this?? or what could you use to make it?

Thank you !

In my game (see signature) I’ve tried both of your suggestions. I have animation events for basic combat and then use a overlapping sphere to check for collisions.

For a Boss fight, I added a collider on the bosses weapon because he was much bigger and I needed more control, however I’ve had a lot of problems with this because it moves so fast and sometimes things don’t collide.

I am working on a mobile game, so I’ve optimized the dynamic settings, which is probably the reason I’m having issues with the dynamic collision, so you might not have any problems with this approach at all.

I guess for you it really depends on the game, if you are working on a fighting game with close up characters, I would use the dynamic approach and tweak the settings, but if the characters are smaller on screen and collision doesn’t need to be as accurate, then try a overlapping sphere.

nice game have you done…

mine is similar than yours…
i will try with overlapping sphere… i´m new to it… never used it before… there is no close up execution…

my game is for android too. i must to check performance …
thank you so much!