Hi i am trying to play animation of an instantiated (clone) object in an another script. But cant get it work.
So i am basically spawning an enemy (enemy has its own Tk 2d sprite and 2k 2d sprite animator component)
Here is a sample code :
tk2dSpriteAnimator anim;
void Start()
{
anim = GetComponent<tk2dSpriteAnimator>();
SpawnMonster();
}
void SpawnMonster()
{
...
....
GameObject enemy = (GameObject)Instantiate(objectsToSpawn[i], spawnLocations[i].position, Quaternion.identity);
//how can i play animation of an instantiated enemy object here ?
if (!anim.IsPlaying("Move Enemy")) //this wont work because it only looks for animation component of current gameobject(which has no animation) i should reach the instantiated game object's animation but how ??
anim.Play("Move Enemy");
}