Move area2d not working on mobile android (InputEventScreenTouch)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By javac

Hi,

I have the code below working correctly on computer, when I click and drag, it moves the area2d.
But when deploy to mobile android the area2d go to the top of the screen and have a completely different behavior.

Thanks in advance

var _canMove:bool = false

func _on_area2d_input_event(viewport, event, shape_idx):
if event is InputEventScreenTouch:
	if event.is_pressed():
            	_canMove = true
	if not event.is_pressed():
			if _canMove:
                    		_canMove = false

func _physics_process(delta):
if _canMove:
	global_position = lerp(global_position, get_global_mouse_position(), 25 * delta)
else:
	global_position = lerp(global_position, _myInitialPosition, 10 * delta)

Solution:

It was a option that needs to be active. Go to menu:
Project → Input Devices → Pointing → emulate mouse from touch (on)

It could be the screen resolution.

Check it out here.
Make collisions visible and check on pc
Multiple resolutions — Godot Engine (stable) documentation in English

ramazan | 2022-04-11 10:00