- Home /
Play animation with external trigger (Sprite manager 2)
How can I activate a packedsprite animation with an external trigger?
I want the player to walk into a trigger and then activate an animation further away.
I tried this script attached to a trigger object, but I can't get it to work.
function OnTriggerEnter(col : Collider) {
packedSprite.PlayAnim("hoppa");
}
Please help me out guys.
Comment
so you want it so that when the player gets to a certain point, it makes an animation play somewhere else?
Best Answer
Answer by yigo2413 · Jan 28, 2012 at 10:40 PM
i think it must be like this :
function OnTriggerEnter(col : Collider) {
if(col.gameObject.tag == "objectTag") //tag or name
{
packedSprite.PlayAnim("hoppa");
}
}
by the way you need to get component from PackedSprite.cs
you can use
var sprite : PackedSprite = gameObject.GetComponent("PackedSprite") as PackedSprite ;
or
var script : $$anonymous$$onoBehaviour ;
and select the gameobject.