using UnityEngine; public class AnimationController : MonoBehaviour { public Animator anim; void Update() { if (Input.GetKeyDown(KeyCode.Space)) { anim.SetTrigger("Jump"); } } }
using UnityEngine; public class AnimationController : MonoBehaviour { public Animator anim; public float speed; void Update() { if (Input.GetKey(KeyCode.W)) { anim.SetFloat("Speed", speed); } else if (Input.GetKey(KeyCode.S)) { anim.SetFloat("Speed", -speed); } else { anim.SetFloat("Speed", 0); } } }The UnityEngine Animator package is provided by the Unity game engine and is part of the standard libraries included with the engine.