How can I make a script that plays a animation when I press a movement key?
using UnityEngine;
using System.Collections;
public class AddSpeedRigidBody : MonoBehaviour {
public float speed = 10.0F;
public float rotationSpeed = 100.0F;
void Update() {
float moveVertical = Input.GetAxis("Vertical") * speed;
float moveHorizontal = Input.GetAxis("Horizontal") * rotationSpeed;
moveVertical *= Time.deltaTime;
moveHorizontal *= Time.deltaTime;
transform.Translate(0, 0, moveVertical);
transform.Rotate(0, moveHorizontal, 0);
}
}