Control the Animation

Hi every body,
i read the Nice Manual (Unity - Manual: Animation),
and i made a very simple Animation (New Model and not Legacy),
in order to control this Animation from within a simple Script, do i have to make it “Legacy” or there is No relation between these two subjects ??
i am really confused at this point …
Please help me How to Control the Animation (Start-Stop-Pause…) from within a Script WITHOUT mixing the Legacy Subject
Many Thanks…

you need to use an animation controller you can go to the docs or go youtube, there is tons of tutorials about that

First : Thank you four your quick answer,
Next : Yes i know this, i already made this as in the attached photo,
and in the “theMotion” Script, i wrote like this :

void Update() {
if (Input.GetKeyUp(KeyCode.Space)) { GetComponent().Play(“GreenSprite”);}
if (Input.GetKeyUp(KeyCode.M)) {GetComponent().StopPlayback();}
}

But, unfortunately, i have TWO problems :

  1. the Animation Starts as soon as i Run the Program
  2. i can NOT control it by pressing Space or M …

Thanks to any Help…

3079613--231810--Look.png

Do you have root motion turned on?