screen drag camera

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

Guys may i know how to move camera by dragging the screen? i need that in my game… I have no idea how to do it… I am dooing 3d game.

:bust_in_silhouette: Reply From: volzhs

Hi what i mean is… dragging screen for touch screen… there is Event.SCREEN_TOUCH right? but how can i get those x and y position so my camera will depend on that value.

alvin00221 | 2016-06-16 01:49

:bust_in_silhouette: Reply From: sandheaver

I’ve never used a 3D camera but in 2D, I would try something like this:

extends Camera2D

func _ready():	
    set_process_input(true)

func _input(event):
    if event.type == InputEvent.SCREEN_DRAG:
	    self.move_local_x(event.relative_x)
	    self.move_local_y(event.relative_y)
	

It worked for me. Thanks.

AlighaThor | 2017-12-19 16:50