+3 votes

I'm trying to make touchscreen controls on my game for android , i added a new input in the InputMap called "click" that is simply the left click of the mouse.
Now on PC the controls work very well but after exporting to android the mouse emulation from touch seems to not work at all
Here's the code for the controls:

extends Node2D

var first_point=Vector2(0,0)
var second_point=Vector2(0,0)

func _physics_process(delta):
    update_position()
    pass 

func update_position():
    if(Input.is_action_just_pressed("click")):
        first_point=get_viewport().get_mouse_position()
        self.show()
    if(Input.is_action_pressed("click")):
        var app=get_viewport().get_mouse_position()-first_point
        second_point=app
    else:
        self.hide()
        first_point=Vector2()
        second_point=Vector2()

Here's a video that shows that on PC works normally
https://mega.nz/#!3wFGhCbQ!BMmEBR79o_Jl2TBh8CkM92q184y4sLPHhksa9NsJJB8

in Engine by (43 points)

1 Answer

+7 votes
Best answer

Ok problem found
In the InputMap set the mouse click to "all devices" and not "device 0"

by (43 points)

Thank you so much!
TBH I think "all devices" should be default setting.

Omg thanks for this solution. I thought I had to do some serious refactoring, because I have similar code.

Thank you so much for this, I went through the exact same loop :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.