Hi, so you'd need to add the buttons and lets say they are $Button_UP
, $Button_DOWN
, etc.
First of all, I recommend you move all that logic to a
func _input(event):
If not, you're checking for input in every iteration of that sprite when you shouldn't be.
So just copy and paste all the content of your _physics_process
function but the move_and_slide(velocity)
line and the rotate_z
lines.
Then add to every condition needed, the $Button_(DIRECTION)
.pressed condition to check if the button is being pressed. So the first condition you have would look like this:
if (Input.is_action_pressed("ui_right") or $Button_RIGHT.pressed) and (Input.is_action_pressed("ui_left") or $Button_LEFT.pressed):
velocity.x .....
Hope it helps. If you need further clarification, let me know.