Как проиграть анимацию через скрипт в Unity?

Помогите! Галочку на Legacy я поставил в окне Animation всё работает, но когда я запускаю игру ничего не работает:(`using System.Collections; using System.Collections.Generic; using UnityEngine;

public class Controler : MonoBehaviour {

public GameObject sprite;
public float speed = 0.01f;
public bool l;
public bool r;
public Animation anim;



void Start()
{
    
}


void Update()
{
    
    if (Input.GetKeyDown(KeyCode.D))
    {
        
        r = true;
        

    }
    if (Input.GetKeyUp(KeyCode.D))
    {
        
        r = false;
    }
    if (l == true)
    {
        
        this.transform.Translate(-speed, 0, 0 * Time.deltaTime);

    }
    if (Input.GetKeyDown(KeyCode.A))
    {
        
        l = true;
        // sprite - объект с анимацией 
        anim = sprite.GetComponent<Animation>();

        anim.Play("left");

    }
    if (Input.GetKeyUp(KeyCode.A))
    {

        l = false;
    }
    if (r == true)
    {
        

        this.transform.Translate(speed, 0, 0 * Time.deltaTime);

    }
}

} `


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