I have another way of doing it.
It is mostly like BloodRedDragons' way, but little different.
If you have punch animation that contains the whole punch move, you want him of course do
the move completely. So you can do it like that:
Create variable -> Attack - Integer - Global - Array: no
Key down, the key you want, repeat disable, script editor:
- Code: Select all
if (Attack == 0)
{
ChangeAnimation(put here your punch animation);
Attack = 1;
}
And then, animation finish, punch animation, script editor:
- Code: Select all
Attack = 0;
And in enemy, collision, any side, main actor, repeat yes, script editor:
- Code: Select all
if (Attack == 0)
{
//Put here the code that takes life away.
}
if (Attack == 1)
{
DestroyActor("Event Actor");
}
This way you can hit once, then it plays the animation and then enables hit again when animation finishes.
And if you're colliding enemy while you punch, you will kill him.
I hope this helps you!