It says it in the title. I want to make the character turn right, left and backwards smoothly instead of instantly but with my script so far it looks glitchy for example when i jump and land but i was moving forward the player just plays the standing animation while moving instead of the run animation.
here is my script.
using UnityEngine;
using System.Collections;
public class Animation : MonoBehaviour {
private MouseLook camera;
public float time = 1f;
public float speed = 1f;
// Use this for initialization
void Start ()
{
animation.Play("Standing");
animation["StandToRun"].speed = 1f;
animation["RunToStand"].speed = 1f;
animation["Jump"].speed = 1.15f;
Screen.lockCursor = true;
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
GameObject.Find("Player").GetComponent<MouseLook>().enabled = false;
GameObject.Find("Camera").GetComponent<MouseLook>().enabled = false;
}
if(Input.GetMouseButtonDown(0))
{
Screen.lockCursor = true;
GameObject.Find("Player").GetComponent<MouseLook>().enabled = true;
GameObject.Find("Camera").GetComponent<MouseLook>().enabled = true;
}
print (transform.localEulerAngles.y);
if(Input.GetKeyDown(KeyCode.W))
{
animation.CrossFade("Run");
}
if(Input.GetKeyUp(KeyCode.W))
{
animation.CrossFade("Standing");
transform.Rotate(0,0,0);
}
if(Input.GetKeyDown(KeyCode.D))
{
animation.CrossFade("Run");
transform.Rotate(0,90,0);
}
if(Input.GetKeyUp(KeyCode.D))
{
animation.CrossFade("Standing");
transform.Rotate(0,270,0);
}
if(Input.GetKeyDown(KeyCode.A))
{
animation.CrossFade("Run");
transform.Rotate(0,270,0);
}
if(Input.GetKeyUp(KeyCode.A))
{
animation.CrossFade("Standing");
transform.Rotate(0,90,0);
}
if(Input.GetKeyDown(KeyCode.S))
{
animation.CrossFade("Run");
transform.Rotate(0,180,0);
}
if(Input.GetKeyUp(KeyCode.S))
{
animation.CrossFade("Standing");
transform.Rotate(0,180,0);
}
if(Input.GetKeyDown(KeyCode.Space))
{
animation.CrossFade("Jump");
}
}
}