# Unity animation won't play on trigger. What do I do to fix it?

Ok so I added a play animation line to my trigger script. I made an animation, added it to the trigger object, attached the animation to the trigger, and tested. The target goes to the trigger as it should, deletes the trigger, but the animation never plays. So I check the console, and it's telling me "The AnimationClip 'MazeDoorClose' used by the Animation component 'SuckInTarget' must be marked as Legacy." so I do that, but now the trigger activates before the target gets there, and there is still no animation playing!

I know this sounds confusing so in an attempt to make it easier to understand I made a short video . Sorry for the crappy quality, but hey it's free. Here is the code:

using UnityEngine;
using System.Collections;

public class SuckIn : MonoBehaviour
{

public Transform target;
public float speed;
public string ObjectWithTagToBeDestroyed;
public string ThingToAnimate;

void Update()
{
float step = speed * Time.deltaTime;
target.position = Vector3.MoveTowards(target.position, transform.position, step);
}

void OnTriggerEnter(Collider coll)
{
if (coll.gameObject.tag == "Ball")
{
Destroy(GameObject.FindWithTag(ObjectWithTagToBeDestroyed));
GetComponent<Animation>().Play(ThingToAnimate);
}
}

}


Before you ask yes the animation is on the object as it should be, and as Unity told me to do I marked it as a legacy animation. Any ideas what am doing wrong?

GetComponent<Animator>().SetTrigger("MyTriggerName");