- Home /
Simple Animation Script Question
Hello, I am trying to make a simple idle to run animation script for my controller. I have already started working on one and my problems are that the speed takes too long to wind down to 0 again, so when I let go of the w key the run still plays for a moment before switching to idle, I want it to automatically switch back to idle when I let go of the directional keys. Also, I would like for the animation to play if I press w, a, s, or d. So far only w works to trigger the animation. I was thinking that maybe there is a way to clamp the speed float to .1 and -.1 max so that it is just like on and off for the animation. Not sure, I'll take any suggestions for this for sure.
Thank you very much for your time, it is greatly appreciated!
https://www.youtube.com/watch?v=kQZB-UThJ_0
using UnityEngine;
using System.Collections;
public class CTAnim1 : MonoBehaviour {
protected Animator myAnimation;
// Use this for initialization
void Start () {
myAnimation = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
myAnimation.SetFloat ("speed", Input.GetAxis ("Vertical"));
}
}