I’ve seen a lot of tutorials on how to do unity animations. If you put keys along the transform property, Unity will record the animation in world space.
When you play the animation, it will ignore the current position of your object and it will switch back to the world position where the animation was recorded.
This problem can be solved if you parent the animated model to an empty gameobject. From then on, your animated model will move relatively to the parent.
Now, lets say that I’ve added a smooth animation which moves my object 2 units along the X axis. I’ve parented this model to an empty gameobject.
I’ve added just 2 keyframes, one at time 0 with transfrom.position at (0, 0, 0) and one at the ending time with transform.position at (2, 0, 0).
Everytime I hit a button I want my animation to play. When my animation plays, it animates correctly the 1st time, but the 2nd time the position resets to the (0, 0, 0) and goes to (2, 0, 0) again! I would like it to go to (4, 0, 0) the 2nd time.
If I had moved the parent along with the child to the new position, then the child would have moved 4 units along the X axis the 2nd time of the animation (in total, if you sum up the 1st and the 2nd animation).
So, what is the solution to my problem? Should I move the parent object along with the child? Should the parent play the animation, and, if I record the animation for the parent object, shouldn’t it have a parent itself so as to avoid the world to local space problem?
I posted this at Unity Answers as well, but I didn’t get any responses. I hope I was understandable.