Hey guys, it’s been awhile since I’ve ask a question. I’m having a problem with my script that supposed to play an animation after I grab a power up. It won’t work and I can’t figure out why.
public class AnimTest : MonoBehaviour {
GameObject BoostPowerupSpawn;
void OnTriggerEnter2D ( Collider2D Other ){
if(Other.gameObject.tag == "Player"){
BoostPowerupSpawn.animation.Play("Boost");
}
}
}
“BoostPowerupSpawn” is the name of the gameobject for the power up. “Player” is the name of the tag for the player/character. “Boost” is the animation I want to play. Both the power up and the player have animator attached to them. When I put this script on my power up, it looks like this. When I tried to put it on my player, the BoostPowerupSpawn changes to Character, the tag Player changes to Item, and the name of the animation changes to “Death”(since I don’t have a boost animation attached to the player yet because this is a test). Please help me. By the way, “Boost” is not in the animator, but I don’t see how that affects anything since Death is in the animator yet that doesn’t work.