- Home /
Animator keeps overriding properties, though the current animation does not touch them
I'm using Unity 2020.3.5f1, and I'm having an issue with the Animator and some Animations.
I have an enemy that has an animation, which enables a few game objects during the animation, for example halfway during the animation.
I have a feature, where an enemy can be stunned, and they will exit that current animation state and move to another "stunned" state, which does not have these previously mentioned game objects as properties.
I wanted to disable these game objects when this event of enemy being stunned happens. However, for some reason, even if I add an animation event that disables them, something keeps enabling the game object right after the animation event happens. I've tried this with several other properties as well, and I do not understand why it happens, I have no other references to these properties in scripts that would enable them, so it's done by the animator.
The animation state that enables these game objects, does not use the Write Defaults flag, but I've tried that as well, but it doesn't fix this issue. Only way I've found this to be solved is to add these game objects as properties to the stunned animation and make that animation set them disabled.
TLDR; Why does the animator keep writing the value of a property of a state, even if that state is not active anymore? Note, this only happens if that animation state was "incomplete" and moved away from through Any State transition to another state.
I encountered this bug with another controller as well, where an animation controlled the position of an object. I noticed that even if this animation was not the entry animation, and had no transitions in or out, it prevented any script from changing the position of the object, as it was constantly overriding the position value.
Only by removing this animation from the controller solved the issue.
Your answer
Follow this Question
Related Questions
Animation Plays well,but teleportation effect happens briefly when parenting the object to other obj 0 Answers
AnimationEvent has no receiver, but there is no AnimationEvent 1 Answer
Is there a way to change the WrapMode of all Animations in a Mecanim Animator? 1 Answer
Dynamically add / remove layers from animation controller through script 0 Answers
Building Tilemap Animations in code require AnimationController 0 Answers