How to make a animation play when a key is pressed?

I have a animation imported from Blender,how do I make it animate when Space is pressed?

Check out Unity’s tutorial series about Animations.

Also if you have any Questions, try to check Unitys awesome Documentation.
They provide much useful informations, tips and tutorials

First add your animation to the animator window.

Create a new C# script called “animation”.

copy and paste this code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class animation : MonoBehaviour {

public Animator anim;

// Use this for initialization
void Start () {
	anim = GetComponent<Animator>();
}

private void FixedUpdate()
{
	if (Input.GetKeyUp("1"))
	{
		anim.Play("YOUR ANIMATION NAME HERE");
	}

	
	}
}

}

Where it says : if (Input.GetKeyUp(“1”)) – you can change the “1” to any button you want. Where it says YOUR ANIMATION NAME HERE, replace with the name of your animation. Save file.

Attach the script to your player and you should be good to go.

You can add more animations just copy and paste the middle portion of script and assign them different animations and keys.