How can I play an animation with a script?

Hi guys, I’m a bit stuck on how to play an animation from a script, I can’t find a good tutorial for this.

I’m trying to slide a panel in and out. I have an animator component on my panel. The first animation slides the panel in when it’s active. This works great. But now I need to activate the second animation, but not sure how to reference it.

All my code is in a script attached to the GameController, not on the panel (which I’m calling “ScorePanel”).

I thought this would work, but doesn’t:


You was very close:
Firts you need get the component ‘Animator’ not the ‘Animation’.
Second when you use Play function need send a string of the name of animation want to play.
In other words: