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?
Under this object put your RedApple sprite or 3D model (the object that was initially your main object)
Don’t forget to put RedApple position at (0, 0, 0)
Create your animation on RedApple. You can modify x, y and z for your animation.
That’s it! Prefabify RedAppleParent so you can put many of them in your game
If you want GreenApple:
Start from a RedAppleParent
In the GameObject menu chose > Break prefab instance
Rename your object to GreenAppleParent
Inside the GreenAppleParent rename RedApple to GreenApple and modify its sprite
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.