- Home /
Skills controlled by animation (event callbacks and parameters)
I'm making a game with complex spells. The system works well, but I'm not sure if my idea of connecting animations to spells is the best way to go.
Spells are scriptableobjects, just like the SpellDirectories. At start player "learns" (Instantiates) the spells from the assigned directory, so I cannot create the spells player specific (it has lots of characters, like in LOL/Dota). So with this, I only use animation events and (Mecanim) Animator's parameters to control the player's behaviour.
In case of some spells, I need to run a function just in time, for example when a player throws a kunai, in the right frame the animator calls an event for the SkillControl script, which sends the event message to all of the spells, "Throwkunai", then the spells filters if it (with switches) has to do sg with the event (but it can be used to send a "Silence" message to all spells too). Now the problem is that the kunai throw rate depends on the speed of the animation.
Same with a charge, jump (slow motion) and hit spell. I inform the spell if the animation reached the point at which it will jump, then the spell makes the character jump, just like with charge and hit (I cannot make independent states for this skill, because it is little combo, and cannot loop the charge part or 'in air' part of it.
So, is it a common way of doing this, or I'm just making things complex with it? I tried to search for a use case like this, but haven't found anything. Link would be appreciated too. Thanks in advance!
Your answer
Follow this Question
Related Questions
Can the mecanim animators Controller var be set in code? 1 Answer
How to get fileID information so i can just edit Mecanim Animator through script? 2 Answers
Get an Animator state inside an AnimationEvent callback of the last frame 2 Answers
Mecanim Animate Physics - When to use? 0 Answers
Combining two animations to be one 0 Answers