How to play the full animation but not loop the first frame on a key press.
I have made a simple script that plays an animation while i hold a button down. However it loops the first frame of the animation. I want it to play the animation full and repeat while the key is held down. using System.Collections; using System.Collections.Generic; using UnityEngine; public class Animations : MonoBehaviour { public Animator anim; // Use this for initialization void Start () { anim = GetComponent<Animator> (); if (Input.anyKey == false) { anim.Play ("Unarmed-Idle", 0, 0f); } } // Update is called once per frame void Update () { if (Input.GetKey(KeyCode.W)) { Debug.Log ("I pressed W"); anim.Play ("Unarmed-Run-Forward", 0, 0f); } if (Input.GetKey(KeyCode.S)) { play(); } } public void play() { Debug.Log ("I pressed S"); anim.Play ("Unarmed-Strafe-Backward", 0, 0f); } }
Your answer