- Home /
 
               Question by 
               Bullorus · Sep 30, 2015 at 01:19 PM · 
                c#animation2dscripting problem  
              
 
              Play an animation through script
Hello, I have a problem with my animation. When I want to play an animation with OnTriggerEnter2D, nothing happens. I think it has to do with the 'legacy' part of the animation, because when legacy is off, the animation shows when I do it manually, but when legacy is on, it doesn't even work manually. Here is my script: using UnityEngine; using System.Collections;
public class EnemyKill : MonoBehaviour {
 public Transform beginSpawn;
 public Transform player;
 public PlayerController Player;
 public GameObject deathParticle;
 
 // Use this for initialization
 void Start () {
     Player = FindObjectOfType<PlayerController>();
 }
 
 // Update is called once per frame
 void Update () {
 
 }
 void OnTriggerEnter2D(Collider2D other) {
     if (other.tag == "Player") {
         Player.enabled = false;
         Player.GetComponent<Renderer>().enabled = false;
         Player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
         GetComponent<Animation>().Play("EnemyKill");
         Instantiate(deathParticle, player.transform.position, player.transform.rotation);
         Invoke("Respawn", 2);
     }
 }
 public void Respawn() {
     Application.LoadLevel(Application.loadedLevel);
 }
}
Thank you for taking the time to help me.
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                