How to Play an animation state on an animator controller on collision?

I’m able to do it with legacy animations using this code -

  private var hasPlayed = false;
var other : GameObject; 
          function OnTriggerEnter(){
      if(!hasPlayed){
	other.GetComponent.<Animation>().Play();; 
 hasPlayed = true;
    }
}

How would I edit this to use the animator instead of legacy.

I’ve looked around and can’t seem to find an answer. Any help would be appreciated.

private var hasPlayed = false;
var other : GameObject;
function OnTriggerEnter(){
if(!hasPlayed){
other.GetComponent.().SetTrigger(“TriggerForStateToPlay”);
hasPlayed = true;
}
}