Hello everyone. I am having trouble applying single animation clip on all the same copy of object across the scene. I want to apply a single animation clip on multiple objects across the scene.
1 Drag your sprite sheet anywhere on scene.
2 Use the sprite editor to define the individual sub-sprites
3 create an empty game object anywhere on the screen.
4 create a script for that empty object (example “enemyaiscript”) including definition for multiple Gameobjects:
public GameObject enemyai1;
public GameObject enemyai2;
public GameObject …
8 Drag your animator object from left/hierarchy window to the inspector gameobject “enemyai1” slot
9 To the Start() section add enemyai2 = Instantiate(enemyai1) as GameObject;
10 Now you have control over multiple instances of sprite animated objects. You can control them individually, FOR EXAMPLE change their individual positions for each instances of the sprite/animation:
enemyai1.transform.position = new Vector3(0.0f, 0.5f, 0);
enemyai2.transform.position = new Vector3(5.0f, 0.5f, 0);
You can, as long as you apply animation properties to the root object. If your animation clip has properties for some children inside object’s hierarchy, you still can apply it to multiple objects as long as they have their children equally named. For example, if you make an animation for an object A with a child named C (for which you animate position of the transform component, for instance) you can also apply the same animation to object B if it has a child named C. And I was talking about Unity animation all the time btw, not an imported one, which is by design is made for a single object.
p.s. If your animations are simple enough, you can code them as a custom component instead of creating animations, which my be more convenient to share between different objects.