Always wondered how to sync animations with attack effects
Hello. I would like to know how to approach this fact. What would be a good and optimal way to make a character attack (with an animation) and deal damage only on specific points of the animation in a precise way.
I can only think of using animation events to activate/deactivate colliders, but that would make me create an script and attach it to the animated object and I don't really know if that would be the best solution.
I normally use this object structure:
Player (empty object)
- Model (empty object)
- - 3DModel (which is animated)
- Effects (empty object to store particles for example)
- Whatever
Then I add several scripts to the object called "Player" to control movement, stats or wait for the input to attack. If I make the attack using this structure, then I would have to add another script to the object called "3DModel" in order to use animation events.
And what about making damage? Enable/disable colliders? are there better ways to face this?
Dark Souls or Monster Hunter could be a good reference. When you attack the damage is only produced when the weapon actually hits the enemy, it's not like enabling or disabling a box collider in front of the player. I thought I could enable the sword mesh collider using animation events too, but if the animation was fast it wouldn't damage the enemy, it seems not all the animation frames where played.
How do game developers code the attack of a character?
How would you make your player attack properly taking into account its animation?
Thank you in advance.