Destroy Object After Animation is Completed

Hey guys,

Ive managed to get a small prototype working where when the player enters a trigger then a animation is played. The issue im having is that once the animation has played the object should be destroyed but it doesnt seem to do that.

the code i have is:

 private GameObject activationPortal;
 Animator portalActivator;

	// Use this for initialization
	void Start () {
        activationPortal = GameObject.Find("PortalActivate");
        portalActivator = activationPortal.GetComponent<Animator>();

    private void OnTriggerEnter2D(Collider2D other)
        if (other.CompareTag("Player"))

    public IEnumerator PortalAnim(float waitTime)
        yield return new WaitForSeconds(waitTime);


For some reason the Destroy(activationPortal); is never reached.
Unless ive done something wrong.

Any help will be appreciated.


debug and check if the line is beeing executed, and post the result

Your approach is wrong
You destroy the gameobject on line 15.
If you destroy the gameobject that the script is attached to, the script will be destroyed too, so the next line will never execute.