0
\$\begingroup\$

I have a gameObjectOne that has two animation clips: move into the screen and move out of the screen. This gameObjectOne has an animator that checks when each clip has to be played.

Now I duplicated this gameObjectOne via the edit menu and named the copy gameObjectTwo, and to my surprise the animator and the animations still work. I expected that the animation clips were associated with gameObjectOne but this is not the case....

The animation clips are not duplicated. There are still only two clips and one animator in the project window. But when I click on gameObjectTwo in the animation window, you can see that there are two animation clips associated with gameObjectTwo as well.

So my question is: how is this possible? And is there a way to see what is "inside" an animation clip file? If I click in the project window on an .anim file, it doesn't say which gameObject it belongs to.

\$\endgroup\$
1
\$\begingroup\$

For starters if you select the serialization to be Force Text from Editor settings > asset serialization > Force Text and the open the .anim file with lets say notepad++ you can its contents. Now to answer your actual question: Animation files are just encoded information about the movement, rotation ,state change, sprite change etc of a object but they are in no way tied to any particular object. For example lets say you record a animation on a cube that moves it from X=1 to X=10. The thing that is recorded is move a transform from coord A to coord B so you can apply this animation to anything with a transform. I hope I have explained what you needed :)

\$\endgroup\$
  • \$\begingroup\$ Thanks! It's good to know that an animation clip only applies to the components of any clip that you associate it with! I thought I had to create separate .anim files for every gameobject. This is never made clear in any of the tutorials I've seen. One more question though: I have made a "move right" .anim file. This moves the gameobject to the right. The problem is: even though I only animate the transform.x property, the y property is also reset when the animation starts. Can't an animation start from wherever the gameobject is at that time? (rows of cars all moving to the right?) \$\endgroup\$ – Kokodoko Sep 23 '16 at 9:44
  • \$\begingroup\$ I dont think you can use the animation system for that. Your best bet is to move the object trough code. \$\endgroup\$ – Uri Popov Sep 24 '16 at 7:58
  • \$\begingroup\$ I made the animated object a child of a parent object. The animation starts at 0,0,0 but it will be relative to its parent. This way you can use one single .anim file to move a lot of objects from/to different positions. \$\endgroup\$ – Kokodoko Sep 25 '16 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.