- Home /
Why is my game object (door) changing rotation in game mode?
I have a door that looks fine in scene view. It has an animator attached that switches from open to closed based on a Boolean parameter. The animation works fine. But when running in game mode, the door always resets its starting transform rotation to 0. When I uncheck the animator on the object (deselecting it) it maintains its location that I set. Why is the animator resetting its location position? Please forgive my noobness.
Hmmm... Go to the "animation" tab (yes, not "animator") and record the animation while making sure it has the right rotation in the scene. This should now change the animation so that it won't "reset" your door.
look if the animation has "Loop Time" checked in the inspector
Thank you both for your timely responses.
Salmjak- I like your idea, but It seems this will put a bandaid on my problem. This is an asset that I would like to use repeatedly. I don't want to have to record an animation at each location. I am looking into the way I created the animation in Blender and exporting it using the Fbx exporter.
F4bo - I've tried with and without the "loop time" checked. Same result.
maybe if you try to be more specific we could sort what it seems to be a really $$anonymous$$or issue - when you say "the door always resets its starting transform rotation to 0" do you mean it starts again the animation from the beginning or just as it was going back to frame 0 and then it stops there?
Answer by Baste · Nov 28, 2014 at 12:16 AM
So I'm guessing that your animation starts the door at 0 at time 0, and rotates it to something like 90 after a while. That's going to give the behaviour you're seeing - animations are not relative to the world unless you set that up.
So, the way you fix this is like this:
1: Set your door prefab as a child of an empty gameobject. Make sure that the centre of this gameobject is where you want your door to rotate around.
2: Move the animation to the parent gameobject.
3: Now, make sure that the parent always has a rotation of 0 when you place it in the scene, and then rotate only the child object.
This will make the child keep the rotation you placed it in, as it's the parent's rotation that's being animated. The child will only rotate because it's parent is rotating.
It would be a ton easier if you could use localrotation as a curve in the animations, but animations are sucky and not supported anymore, so this is what you've got to work with.
Answer by Johnoss · Dec 04, 2015 at 04:02 PM
I had the exact problem as you did when updated to newer version of Unity3D (boy, took me ages to figure out it was animator related) and you fix it by unchecking Apply Root Motion at related Animator component