Play animation with scripting and Mecanim.

Is it possible to play an animation with only code using the Mecanim system? I want to avoid setting up speed variables and inputs shown in the Mecanim tutorial video - I simply want to animate a model using the animation files provided by the Mecanim system and other animated files. I was hoping you could do this through simple scripting (similar to how the Legacy animation system works, e.g. Animation.Play(“Run”). I’ve set up a character avatar/controller with Mecanim - i’ve placed several animation states into the Animator window - is it possible to use only scripting to play each one of these animations separately? For example, I would want to use something like:

if(Input.GetKeyDown("j"))
{
          Animator.Play("Run");
}

This doesn’t work obviously, and nothing else i’ve tried works - is it even possible to do something like this using Mecanim?

What features do you need from Mecanim, can’t you use the legacy system then?

You’ll still need to set up your states, but could you simply have each state correspond to an animation and play the state with Animator.Play()?