I am totally a noob, im sorry guys
i just want my character to maintain his jump animation while hes off the ground. And also only jump when he is on the ground!
i have no clue how to do this.
Any help would be much appreciated.
this is the script i have for my animations
public float movementSpeed = 10;
public GameObject DirectionObject;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.A)) {
Move(Vector3.left);
GetComponent<Animation>().CrossFade ("walk");
}
if (Input.GetKey(KeyCode.D)) {
Move(Vector3.right);
GetComponent<Animation>().CrossFade ("walk");
}
if (Input.GetKey(KeyCode.W)) {
Move(Vector3.forward);
GetComponent<Animation>().CrossFade ("walk");
}
if (Input.GetKey (KeyCode.S)) {
Move (Vector3.back);
GetComponent<Animation> ().CrossFade ("walk");
}
if (Input.GetKey(KeyCode.Space)) {
GetComponent<Animation>().CrossFade ("jump");
}
if(Input.anyKey == false)
{
GetComponent<Animation> ().CrossFade ("idle");
}
}
void Move(Vector3 direction)
{
var newDirection = Quaternion.LookRotation(Camera.main.transform.position - transform.position).eulerAngles;
newDirection.x = 0;
newDirection.z = 0;
DirectionObject.transform.rotation = Quaternion.Euler(newDirection);
transform.Translate(-direction * Time.deltaTime * movementSpeed, DirectionObject.transform);
Quaternion newRotation = Quaternion.LookRotation(-direction);
transform.rotation = Quaternion.Slerp(transform.rotation, newRotation * DirectionObject.transform.rotation, Time.deltaTime * 8);
}
}