Trigger animation from outside of object

Hi all,

I’m new to Unity and I have a small problem that I couldn’t solve on my own.

I have an object that has an Animator with a Controller and a Trigger.

If I create a script that is attached to the object I’m able to set the trigger like this:

private Animator animator;

void Start () {
animator = GetComponent();
animator.SetTrigger(“Trigger1”);
}

How could I set this trigger from a C# script that is not attached to the object that has the Animator.

Thanks for the help.

I managed to solve it like this:

Animator animator = child.gameObject.GetComponent("Animator") as Animator;
animator.SetTrigger("Trigger1");

There was no need for the other script, I could refer to the Animator component straight.