Unable shoot in all directions (SOLVED)

I followed war battles tutorial and im not able to shoot all directions with my player object, i can shoot every direction except the down-left direction, this is how my code looks:

   function on_input(self, action_id, action)
	-- Add input-handling code here
	if action_id == hash("up") then
		self.input.y = 1
	elseif action_id == hash("down") then
		self.input.y = -1
	elseif action_id == hash("left") then
		self.input.x = -1
	elseif action_id == hash("right") then
		self.input.x = 1
	elseif action_id == hash("fire") and action.pressed then
		self.firing = true
	end

	if vmath.length(self.input) > 0 then
		self.moving = true
		self.dir = vmath.normalize(self.input)
	end

	
end

anyone have a clue why it is like that?

No, that looks ok. What happens when you shoot when facing down-left? Does a rocket spawn? Does it move? In which direction?

Hmm, I had this too when I did the war battles tutorial, I couldn’t shoot in two of the diagonal directions (can’t remember which now, but I think they were opposing directions).
If I stopped moving I could fire a rocket in the right direction if I was quick, but nothing while moving.
But the other directions worked, so it wasn’t to do with three buttons not all working together.

Yeah sometimes i can shoot if i stop moving and im fast, i feel like its random almost, do you remember how to solve it?

I had this issue too. Had to rebind my keys to WASD rather than arrow keys and it worked fine after that. Something to do with the way keyboards are wired up that wont allow certain multiple combinations of keys.

2 Likes

yes now it works! switch to WASD, thank you

1 Like

Ah, interesting to know.