Weird bug about flipX being stuck
So, I have a sprite animation that sets SpriteRenderer.FlipX = true, and as expected, the animation flows flawlessly...
When the animation ends, FlipX is set back to false... there is no script call no nothing, it's just reset.
So I tried using OnStateExit to ensure that after the animation FlipX would be set to true. After coding the calls and checking that they are called, I see that the inspector keeps showing FlipX "unchecked", the property is set to true and the sprite appears unflipped.
Then I tried doing the same thing using animation events, same result.
After that, I tried just clicking the #@&$# checkbox, and guess what? It doesn't work, the box isn't greyed out, it just keeps unchecked and clicking it does not flip the sprite (with the game running or not). Clicking FlipY works perfectly...
I guess that something in mecanim is holding the FlipX property, does anyone have any idea on how to fix this? I just wanted FlipX to stay checked after the end of the animation. I am using root motion and all the other properties keep their values ok.
Answer by Ashkman · May 26, 2020 at 07:39 PM
Sorry for necro'ing this thread but it was the first result for me after looking for a solution to the very same problem OP has. So basically all animations in an animator override default values of properties they change even if that certain animation is not playing, so if you want to adjust a property in script that is changed in one of the animations, you have to do it in LateUpdate.
Also explained here: https://forum.unity.com/threads/animator-locking-animated-value-even-when-current-state-has-no-curves-keys-for-that-value.440363/#post-3041664
Your answer
Follow this Question
Related Questions
Unity Sprite renderer bug?? 0 Answers
2D Sprite doesn't flip across pivot point. 0 Answers
Creating new sprite sheet from attached sprites/textures of SpriteRenderer Components 0 Answers
Why Won't my 2D Animation's Normals Render Unless I Have an Animator 1 Answer
Set the Sorting Layer for UI Controls 0 Answers