- Home /
Animations with rotations breaking ingame object rotations
I have problems applying rotations to a child gameobject after giving it an animation that makes that gameobject rotate, basically the rotations from the script seem to be overriden by the animator even if there is no animation playing.
If its not clear enough, here are the steps to reproduce a simplified version:
I make a sphere in a blank scene and attach two cubes as children, then clone the sphere to have two of them, next I add a script to the spheres that rotates the cube. It works:
Now I add an animator to the right sphere and change its script, until this point everything still works, but as soon as I add an animation (Test) that changes the cube's rotation my cube stops rotating at start, even when the (Default) state has no animation to play:
So my questions are:
Am I missing some option in the animation or animator that will let my cube rotate?
Is there some workaround for this to work?
What's the solution if I want my cube to change rotation in the default state?
Or is the only solution to use another animation that keeps the cube in the rotation I want?
Thanks for your time.
Answer by Faen_run · Sep 23, 2017 at 01:08 AM
Well, guess I can answer my own question.
The most suitable solution I found is to disable the animator when im not using it with (animator.enabled = false) so I need to activate and deactivate it every time I need it. If you deactivate it with an event in the last frame of an animation it will make the animator play that last frame once its active again, to avoid this I had to override the first frame after enabling the animator using lateupdate.