attack_count somehow controlling animations outside it's script.
AidasLit opened this issue · 3 comments
The variable 'attack_count' in 'souls_animation_tree.gd' is only referenced in the same file from what I can tell. The only places where it appears, are it's declaration and setting values. Despite not being used in any other lines, it somehow controls the 'attack' oneshot state_machine state. How does that work?
I must be missing some crucial detail (I can only assume it's something done in the engine editor that i'm failing to notice). Nevertheless, it might be good to make it's usage clearer for anyone else digging into this code.
Correct, it controls animations outside it's script. Those attack_counts are more like "attack_IDs" to be honest. As that number shifts, the advanced expressions in the animation state trees will select the appropriate animation to run during the one shots.
And here is the tutorial video, at the correct timestamp explaining specifically how these work, and how to add your own, etc.
I'll add a note to the code to clarify that further though for folks not watching the tutorials explanations and trying to learn it dry.
Ok that makes sense. I do actually remember this part from back when I watched the video, but that was a while ago so it seems I forgot. I think for my own project I'll handle that in the script, just to have all of the logic in one place. Thanks for the explanation, and thanks for making this whole project, it's been a real help in making the character controller 👍
That's your call. My preference used to be doing that, but i no longer put th elogic in the script because it makes expanding the project harder to do as easily.
Leaving it in the anim tree as expression conditions loosely looking at variables to pick a path is nice so you can change any animation, animation node name, node type, add more nested trees with similar paths setup, etc etc, and it won't break a thing, they all add nicely. Makes for really flexible animation work. Hard coding declared animation triggers and paths quickly gets messy as you expand further into more trees.
With the current method you could add any attack number, and the setup a path for it looking for that number, and you're golden. it'll trigger perfect no mater what you plug into the other net of that node-path.