I'm not sure I'm doing things the right way, but I started testing a draft of my 3D game on PC, then I exported it on android.
First, I wanted my player to follow my mouse pointer when I hold the left mouse button down, so I did this :
func _physics_process(delta):
if Input.is_action_pressed("click"):
position_2D = get_viewport().get_mouse_position()
# then, project ray from camera to get a position_3D and move...
Then, when I wanted to convert the mouse button by adding touch screen support on Android, I found InputEventScreenTouch, but I can't find how to use it in _physics_process, so I put everything in _input(event):
func _input(event):
if event.is_action_pressed("click"):
position_2D = get_viewport().get_mouse_position()
elif event is InputEventScreenTouch and event.is_pressed():
position_2D = get_viewport().get_canvas_transform().affine_inverse().xform(event.position)
The issue is it only detect press event once, so the position is not updated for each frame.
I think I need to put it back in _physics_process, but since I don't have an event instance, I don't know how to do it.
Any pointer? Maybe I'm doing it wrong.