having trouble with my animation script
so i want it to play a animation when the player stands on the object
using UnityEngine; using System.Collections; public class spikeDestroy : MonoBehaviour {
public Animator anmin;
// Use this for initialization
void OnTriggerEnter2D(Collider2D col){
if (col.tag == "Player") {
Destroy (gameObject, 1);
Animation.Play ("anim");
}
}
}
Comment
Answer by vintar · Jun 10, 2016 at 03:55 PM
You need to use the anmin.Play("anim"). Also I would add an event to the end of the animation that destroys the gameobject instead of relying on a timer that may need to change depending on the animation length.
Your answer
Follow this Question
Related Questions
2D Slide Animation 0 Answers
How to use humanoid animations for 2d characters? 0 Answers
Animation location problem! 0 Answers
How can I stop my character from walking during the attack animation? 1 Answer
2D Animation Feet Pivot Point 0 Answers