Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lewislepton | |
Old Version | Published before Godot 3 was released. |
just to ask. rather than post in the forum just now, because i think that this can be updated better.
but doing a simple 4 button movement, up, down , left , right seems to be not working and dont know why. its odd.
tried this type of code in other platforms and its fine.
it works with the last movement code, so left/right is fine, but up/down, nope. not working
here is my code
func _fixed_process(delta):
LEFT_BTN = Input.is_action_pressed('LEFT_BTN');
RIGHT_BTN = Input.is_action_pressed('RIGHT_BTN');
UP_BTN = Input.is_action_pressed('UP_BTN');
DOWN_BTN = Input.is_action_pressed('DOWN_BTN');
if UP_BTN:
self.set_linear_velocity(Vector2(0, -player_speed));
elif DOWN_BTN:
self.set_linear_velocity(Vector2(0, player_speed));
else:
self.set_linear_velocity(Vector2(0, 0));
if LEFT_BTN:
self.set_linear_velocity(Vector2(-player_speed, 0));
elif RIGHT_BTN:
self.set_linear_velocity(Vector2(player_speed, 0));
else:
self.set_linear_velocity(Vector2(0, 0));