i have a script (Item) attached to a tk2dSpriteAnimator called Groopy, telling it to play one animation (randomly between "good" and "bad")
and i have a script (Game) that every few seconds instantiate a Groopy at the door, if the groopy wasn't killed it renames it (by tagging) and then moves the Groopy to a different location.
this is how the Game script looks like -
var prefabs : GameObject[];
var go : GameObject = Instantiate(prefabs[selectedItem] ,Vector3(-6.536877, 0, -0.1),Quaternion.identity);
if ((GroopyCount == 1) && (Item.ClipName == "Good"))
{
go.tag = "GroopyOnSide";
var GroopyOnSideClone : GameObject = GameObject.FindGameObjectWithTag("GroopyOnSide");
var GroopyOnSidePosition:float = GroopyOnSideClone.transform.position.x;
go.transform.position.x = 4;
}
now i want to make the GroopyOnSideClone play a different animation without interfering the Item script that tells the Groopy to play the "good" or "bad" animations at the door.
i tried - GroopyOnSideClone.Play ("BadOnSide")
but unity recognize GroopyOnSideClone as game object and not a tk2dSpriteAnimator so i get an error.
i also tried AddComponent and wrote this function to the Item script -
function ControlGroopiesOnSide ()
{
var GroopyOnSideObject : GameObject = GameObject.FindGameObjectWithTag("GroopyOnSide");
var GroopyOnSideAnim:tk2dSpriteAnimator = GroopyOnSideObject.AddComponent(tk2dSpriteAnimator);
GroopyOnSideAnim.Play ("BadOnSide");
}
but got the error "MissingFieldException: Field 'tk2dSpriteAnimator.Libary' not found."
so my question is - is it possible to tell the same tk2dSpriteAnimator to play different animations to different tagged objects and if so how do i do it.
thanks!
chen