For my game, I need to be able for the user to drag the player but the player should stay locked on the X axis as to avoid the incoming blocks. But how could I implement that ? Right now I have got some basic code that moves the player when TAPPING and not by dragging.
It would be good to familiarise with the other InputEvent types here:
You will find directly below InputEventScreenTouch is InputEventScreenDrag which should suffice.
As for locking the player to the x axis, just comment out line 24?
edit: and remove the inline if statement. Not sure what purpose this serves. Surely it’s just:
func _input(event):
if event is InputEventScreenDrag:
position.x = event.position.x