- Home /
Can't change transform rotation of GO with an animation that change it's rotation
Hi all, I have a GameObject with an animator that has two state:
Idle: a state without animation that is my default state
TestRotation: a state with an animation that rotate the GO on Y axis.
The problem is that when the animator is in the Idle state I can't change the transform rotation, neither from script, neither from inspector. It seems that Unity locks the rotation of the object if there is an animaton in the animator that has the rotation property.
If i remove the rotation animation from the rotation state, the rotation of the GO is unlocked.
Is there a workaround to solve this problem? Considering that in my project i can't put the GO in an empty GO to manage it's rotation from the parent.
Thanks for your help, Simone
I came across the exact same problem, did you find any solution?
Answer by Faen_run · Sep 23, 2017 at 12:59 AM
Ok, I came accros this same problem and got a good enough solution, once Im done with the animations I disable the animator component with( animator.enabled = false; )
In my case I disable the animator in the last frame of the animation and it leaded to some flickering after enabling it back (the last frame of the last animation would play), so I had to use lateupdate in the first frame after enabling the animator to "override" the animator.
Answer by theANMATOR2b · Jul 30, 2017 at 09:22 PM
Im not a coder - but I think this can be accomplished by rotating the model in late update, - this happens after the animation has been processed. But I'm only guessing - and I think this is not advised.
Check Unitys processing stack - where they list what is processed first - last. I know things can be performed after the animation step, where the animation is processed.
I don't think is a good practice to just override the rotation in the lateUpdate. Also the thing I want is to position my object in various points in the scene with different rotation (sometimes animated with the testRotation and sometimes static, rotated toward a specific point). The thing is that I can't do this and have the testRotation in the animator, cause the animation override the rotation I set from code, a single line of a function that is not called in an update...
Thanks for your answer though
Answer by akistrollmail · Jun 09, 2020 at 08:55 PM
You could also just parent your object to an empty object and move that instead