я сомостоятельно хотел добавить анимацию своему персонажу но ничего не получилось

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

public class PlayerMove : MonoBehaviour
{
    public float speed = 1f;
    public float jumpForce = 5f;
    
    Rigidbody2D rb;
    SpriteRenderer sr;
    Animator anim;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
        sr = GetComponent<SpriteRenderer>();
    }

    void Update()
    {
        if movement = Input.GetAxis("Horizontal")
        {
             transform.position += new Vector3(movement, 0, 0) * speed * Time.deltaTime;
             animator.Play("Run");
        }

        else if (Input.GetKeyDown(KeyCode.Space) && Mathf.Abs(rb.velocity.y) < 0.05f)
        {     
             rb.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);
             animator.Play("jump");
             
             sr.flipX = movement < 0 ? true : false;
        }     
        else
        {
             animator.Play("idle"); 
        }          
    }
}

Ответы (0 шт):