Question by
KleinGames · Jan 07, 2017 at 12:33 AM ·
inputinputmanagergetaxis
Pressing two buttons on the xbox D-pad but not moving both directions at once
I already set up my Input manager. Lets say i press the Up arrow and Right arrow on my keyboard, the player will take in both those inputs. When i use the xbox controller and press Up and Right on D-pad it only takes in the first input pressed and ignores the other.
This is the code i have on my player:
public float jumpSpeed = 15f;
public Rigidbody rb;
bool isJumping = false;
Animator anim;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody> ();
isJumping = false;
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
if (Input.GetKey ("up") || Input.GetAxis("Horizontal") == 1) {
transform.Translate (Vector3.forward * 1 * Time.deltaTime);
anim.Play("rabbit_move");
}
if (Input.GetKey ("down") || Input.GetAxis("Horizontal") == -1) {
transform.Translate (Vector3.back * 1 * Time.deltaTime);
anim.Play("rabbit_move");
}
if (Input.GetKey ("right") || Input.GetAxis("Turn") == 1) {
transform.Rotate (0, 200 * Time.deltaTime, 0, Space.World);
}
if (Input.GetKey ("left") || Input.GetAxis("Turn") == -1) {
transform.Rotate (0, -200 * Time.deltaTime, 0, Space.World);
}
if (Input.GetKeyDown ("space") && isJumping == false || Input.GetButton("Jump") && isJumping == false) {
isJumping = true;
rb.AddForce (Vector3.up * (jumpSpeed * 2.2f));
anim.Play("rabbit_jump");
}
}
void OnCollisionEnter(){
isJumping = false;
}
Comment
Your answer
Follow this Question
Related Questions
This is weird - Assembly hi could not be loaded 1 Answer
Input Keyboard GetAxis not working 0 Answers
Input.GetButton not working 1 Answer
Custom input not appearing in input manager 0 Answers
Rebind - Excluding Certain Keys 0 Answers