Hi, this is the snippet of relevant code:
void Update () {
if (Input.GetKey (moveRight) && canMove == true) {
rigidbody2D.velocity = new Vector2 (speed, 0);
} else if (Input.GetKey (moveLeft) && canMove == true) {
rigidbody2D.velocity = new Vector2 (speed * -1, 0);
} else if (Input.GetKey ("space") && canMove == true && canJump == true) {
rigidbody2D.velocity = new Vector2 (0, jumpHeight);
this.canJump = false;
} else if (Input.GetKey (moveRight) && Input.GetKey ("space") && canMove == true && canJump == true){
rigidbody2D.velocity = new Vector2 (0, jumpHeight);
} else { rigidbody2D.velocity = new Vector2(0,0);
}
}
As you can see I can move and I can jump however I can’t move and jump. From research I know you have to && the move and jump so I have the else if (Input.GetKey (moveRight) && Input.GetKey (“space”) && canMove == true && canJump == true){
rigidbody2D.velocity = new Vector2 (0, jumpHeight);
Where space is my jump button since it gets both keys for move right and jump I would assume I could jump while holding the right arrow but I can’t. As it is right now I have to let go of all keys before I can jump and I do not know why.