- Home /
Can the animation editor create local rotational data?
I made a simple animation in the animation editor (a door swinging open) and then save this door with its anim to a prefab. Then when I duplicate the prefab and rotate the door to fit in different doorways the animation always plays from a fixed 'global' rotation ie the start and end positions of the original door..the prefab rotations arent taken into account.
How do I make the animation follow local rotations? If thats not possible it makes the animation system useless for prefabs right?
Answer by Futurerobot · Aug 08, 2012 at 04:31 PM
Objects rotate and position themselves in the coordinate system of their parent objects, same when animated. The "local pivot" on the parent shows you the center and orientation of the coordinate system. If you animate the Y position of an object, it will move along the Y direction of the parent coordinate system. Rotations are a bit more fancy but still basically the same.
An object without a parent is basically moving around in the unity world coordinate system. Animations done in the world system will always put the object in the same spot and orientation as you animated them. Moving them around does not have any effect, since the animation controls the position and rotation values while it's running.
In the door example:
Create an empty GameObject and call it for instance "DoorParent", then link the door to it. When you now animate the door opening, the movement is happening in the doorparent coordinate system, and moving the doorparent around allows you to position the door with the animation intact.
Answer by Aubrey Hesselgren · Apr 03, 2011 at 09:00 PM
As a basic best practice, specifically for the kinds of problems you're getting here, you should only really animate children of the object you've added the animation component to.
Answer by Paulius-Liekis · Apr 20, 2010 at 09:02 AM
You're doing something wrong (can't really say what). Animations work in "local space", so if you move parent everything should work. If it wasn't supported it wouldn't be possible to do any character controllers using such animation system.
Your answer
Follow this Question
Related Questions
Can I make animations snap to a frame? 1 Answer
Scripted mesh combine with animation such as Armor, Clothing, etc. 0 Answers
Instantiated Bullet Lags Behind Animated Timeline Object 1 Answer
Why have some of my prefabs and animations files gone blank?? 1 Answer
Problem to play animation in C# 5 Answers