Touchscreen position and camera2D .

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DriNeo
:warning: Old Version Published before Godot 3 was released.

I created a moving object followed by a camera for Android. This object moves to reach the point previously touched on screen.

func _input(ev):
 if (ev.type == InputEvent.SCREEN_TOUCH):
  newDestination(ev.pos)

But the camera is ignored. If I touch the screen outside the original viewport the object can’t moves outside these original limits .

The mouse provides more options like the global pos, local pos etc… I haven’t found the same to capture touch inputs.
Thanks in advance for some ideas.

You can make the event local to the object with make_input_local though ;). Edit: I made this into an answer, see below

Bojidar Marinov | 2016-04-05 14:14

It’s an helpful suggestion I’m going to study it. make_input_local wants an inputevent as argument. And the InputEvent class can’t be instancied with new() function. I found an instance of InputEvent only into the _input function.

func _input(ev):
 event = myObject.make_input_local(ev)  # this line runs at every input event is it good ?
 if (event.type == InputEvent.SCREEN_TOUCH):
  myObject.newDestination(event.pos)

It works thanks again ! But I wonder if this is the regular way to use make_input_local ?

DriNeo | 2016-04-05 21:15

Yeah, that’s the right way to use it… should I make my comment an answer?

Bojidar Marinov | 2016-04-06 06:23

Yes, I will select your answer.

DriNeo | 2016-04-06 10:03

:bust_in_silhouette: Reply From: Bojidar Marinov

You can make the event local to the object with make_input_local. E.g.

func _input(event):
    var local_event = make_input_local(event)
    if local_event…