I’m making a 2d platformer, and I’ve already figured out how to make the player character jump. However, I want to play a jumping animation for whenever the player jumps. Here is my current script, though it should be noted that I’ve been using the Animator.
public class JumpScript : MonoBehaviour
{
public float jumpHeight;
void Start()
{
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
GetComponent<Rigidbody2D>().AddForce(Vector2.up * jumpHeight);
GetComponent<Animation>("PlayerJump");
}
}
}