How to play one animation using animator on different positions?

Hello everybody,

I have a problem. I created an animation on a gameobject RedApple. Then I added a component animator to the RedApple and linked the animation using SetBool when triggered. Then I added a GreenApple to the scene to a different possition, added an Animator component and linked the same animation. The result I want is to play one animation on different positions. What I get is same animation on one position where the animation was created even when two different gameobjects have different positions… How should I solve it?

Thanks a lot.

Edit: I put one of my comments as an answer:

You need to recreate your animation.

  1. Create one empty object called RedAppleParent
  2. Under this object put your RedApple sprite or 3D model (the object that was initially your main object)
  3. Don’t forget to put RedApple position at (0, 0, 0)
  4. Create your animation on RedApple. You can modify x, y and z for your animation.
  5. That’s it! Prefabify RedAppleParent so you can put many of them in your game

If you want GreenApple:

  1. Start from a RedAppleParent
  2. In the GameObject menu chose > Break prefab instance
  3. Rename your object to GreenAppleParent
  4. Inside the GreenAppleParent rename RedApple to GreenApple and modify its sprite
  5. That’s it! Prefabify GreenAppleParent so you can put many of them in your game

Initial answer: When you recorded your animation you probably recorded the transform position at the same time. Therefore the animation forces the object to be at a certain position. Remove the transform keys (x, y, z) from your animation and you should have better results.