+1 vote

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.

in Engine by (45 points)

2 Answers

–1 vote
by (9,688 points)

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.

+2 votes

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)
by (99 points)

It worked for me. Thanks.

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.