Play animation on death?

Hello,

i have done some tutorials to creat my first game.

To finish the project i have to add a menu that pops out when the player dies.
Is it possible to play the "menu pop out"animation on collision if the animation is a “animator” animation?

I got this code:

	void OnCollisionEnter2D(Collision2D collision) {

		if (godMode)
		return;

		animator.SetTrigger("Death");

      //use other code to start animation. setTrigger will stop "death"animation
          //animator.SetTrigger("DeathMenuOpen"); 
		dead = true;

		}
	}

I tried to use the animator but if i use the “set.trigger()” code, the death animation will end.

Create the menu open animation and put the animation on the gameobject and call the animation using animation.Play
you dont need animator

Problem solved! I had to make sure the animation is in legacy mode and the object with the animation is assigned in the inspector.

    using UnityEngine;
    using System.Collections;
    
    public class PlayerMovement : MonoBehaviour {
    
    	public GameObject MenuObj;
    
    
    	void OnCollisionEnter2D(Collision2D collision) {
    
                    //play animation of the menu when player collides with something!
    		MenuObj.animation.Play ("BirdMenuOpen");
    
    
    		}
    		
    	}

sometimes it is to easy … :7