Unity version is 3.5
The problem I am having is that when I go forward backwards left or right and then change directions my animations don’t stop and even when I don’t change the character will stop and is running staring or moving backwards in place.
Not really sure what I did wrong.
Here is my script.
using UnityEngine;
using System.Collections;
public class PlayerScript : MonoBehaviour
{
public float mySpeed;
public float rotateSpeed;
public static CharacterController characterController;
void Start()
{
characterController = GetComponent<CharacterController>();
animation.CrossFade("Idle");
}
void Update()
{
if (Input.GetAxis("Vertical") > 0)
{
characterController.Move(transform.forward * mySpeed * Time.deltaTime);
animation.CrossFade("Running");
Debug.Log("Forward");
}
else if (Input.GetAxis("Vertical") < 0)
{
characterController.Move(transform.forward * -mySpeed * Time.deltaTime);
animation.CrossFade("WalkBackwards");
Debug.Log("Backwards");
}
if (Input.GetAxis("Horizontal") > 0)
{
characterController.Move(transform.right * mySpeed * Time.deltaTime);
animation.CrossFade("StrafingRight");
Debug.Log("Right");
}
else if (Input.GetAxis("Horizontal") < 0)
{
characterController.Move(transform.right * -mySpeed * Time.deltaTime);
animation.CrossFade("StrafingLeft");
Debug.Log("Left");
}
transform.Rotate(new Vector3(0, Input.GetAxis("Horizontal") * rotateSpeed * Time.deltaTime, 0));
}
}