Wie zu spielen eine AnimationClip wenn die Taste gedrückt wird, in Unity3d, C#?

  1. Ich versuchte diesen code, aber es funktioniert nicht.
  2. Kann mir jemand helfen, und kann mir jemand erklären, was zu Animationen in Unity 3D? Ich habe schon so viel ausprobiert, google, youtube usw.

    using UnityEngine;
    using System.Collections;
    
    public class PlayAnimation : MonoBehaviour {
    
        public AnimationClip walk;
        Animation anim;
    
        void Update () {
            if (Input.GetKeyDown(KeyCode.W)){
                anim.clip = walk;
                anim.Play();        
            }
        }
    }
  • Du bist nie zu tun anim = GetComponent<Animator>(); in der Start-Methode?
Schreibe einen Kommentar