I was wondering if it would be easier to add a property to your animation and change the speed variable that way? I understand animation events are useful for calling methods that may deal damage or do anything more than simply change a variable. However, it seems that adding a property is a better way to change variables within a script because it saves you making a new public method and having to mess around with the clunky string names.
[Edit] However, it seems that adding a property only works if the variable is serialized.
I’m not sure if I understood you correctly but you cannot add any properties to the animation. Maybe you can add a component to it and access a property of that component/instance but I have not tested that.
Neither Unity nor the animation know anything about “speed”. “Speed” is meaningless without a context. The context is your script.
This is what i meant by adding properties to an animation. Speed is the name of a serialized variable within my Attacker class. My Lizard_Walk animation sets the variable to 1 and my Lizard_Spawn animation sets the variable to 0. Then the movement is handled within the script as usual.