Certain input actions don't work with others when pressed at the same time?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nichefect
:warning: Old Version Published before Godot 3 was released.

In my game there is a player controlled character node(a circle) that can move and shoot. I have it so that a “Controller” node acknowledges input and switches its boolean variables accordingly, while the “Player” node instances the controller and acts accordingly to those boolean values as such:

Controller code:

func update(delta):
# update movement controls
if(Input.is_action_pressed("right")):
	right = true
else:
	right = false
if(Input.is_action_pressed("left")):
	left = true
else:
	left = false
if(Input.is_action_pressed("up")):
	up = true
else:
	up = false
if(Input.is_action_pressed("down")):
	down = true
else:
	down = false
# update attack controls
if(Input.is_action_pressed("shoot_right")):
	shootRight = true
else:
	shootRight = false
if(Input.is_action_pressed("shoot_left")):
	shootLeft = true
else:
	shootLeft = false
if(Input.is_action_pressed("shoot_up")):
	shootUp = true
else:
	shootUp = false
if(Input.is_action_pressed("shoot_down")):
	shootDown = true
else:
	shootDown = false

Player code:

func updateMovement(delta):
var controller = get_parent().get_node("Controller")
var velocity = Vector2()
if(controller.right):
	velocity.x += SPEED
if(controller.left):
	velocity.x -= SPEED
if(controller.up):
	velocity.y -= SPEED
if(controller.down):
	velocity.y += SPEED
var motion = velocity*delta
move(motion)
if(is_colliding()):
	var n = get_collision_normal()
	motion = n.slide(motion)
	velocity = n.slide(velocity)
	move(motion)

func updateAttack():
if(!controller.attackActive):
	return
var scene = load("res://Weapon.tscn")
var weapon = scene.instance()
get_parent().add_child(weapon)
if(controller.shootRight):
	weapon.velocity.x += weapon.SPEED
if(controller.shootLeft):
	weapon.velocity.x -= weapon.SPEED
if(controller.shootUp):
	weapon.velocity.y -= weapon.SPEED
if(controller.shootDown):
	weapon.velocity.y += weapon.SPEED

So essentially what is going here, is that the player can move either left, left-up, up, right-up, right, right-down, down, or left-down, and can also shoot in any of these directions. The problem, is that if the player is going in a certain direction, they cannot shoot in another certain direction, or vice-versa. For example, when the player is shooting down-left, they will not be able to move down-left, but they can move left. Also, if the player is shooting down-left, they will not move right. I am completely perplexed as to why this is.

Things I have tried:

  • Not using the controller node and instead handling input directly in the player move and attack functions.
  • Monitoring the input actions to see if they respond when they should. They don’t if I am shooting down-left and press “D” to move right, the action for moving right doesn’t even trigger.

Note: the {if(!controller.attackActive): return } line was added after the fact so that isn’t part of the problem.

Have you tried using arrows instead of WASD? to discard a keyboard issue

eons | 2017-01-09 00:54