- Home /
Question by
AlexTheHollow · Sep 20, 2015 at 07:41 AM ·
spritescript.2d animation
2D Animation Won't Allow Player To Move
I'm trying to get my character to move while the walking animation is played but it just holds the character in place. The Idle won't play constantly anymore either and I can't seem to get the jump to work.
Here's the script I'm using:
using UnityEngine;
using System.Collections;
public class PlayerMove : MonoBehaviour {
public float speed;
void FixedUpdate () {
if (Input.GetKey("a")) {
transform.Translate (-Vector3.right * speed * Time.deltaTime);
GetComponent<Animation>().Play("FBRunRight 1");
}
if (Input.GetKey("d")) {
transform.Translate (Vector3.right * speed * Time.deltaTime);
GetComponent<Animation>().Play("FBRunRight 1");
}
if (Input.GetKey ("space")) {
transform.Translate (Vector3.up * speed * Time.deltaTime);
GetComponent<Animation>().Play("FBJump 1");
}
}
}
All help is appreciated!
Comment