0 votes


I would like to allow zooming in and out on cellphone. What signals should I look for? I guess zooming in would be triggered by two fingers getting closer on the screen, while zooming out would be triggered by two fingers getting farther away.

Thank you for your help.

in Engine by (19 points)

2 Answers

0 votes

InputEventScreenTouch has the index property so you should be able to check the index number, get the two positions and get the length of position 0 - position 1

var positions : Array = [Vector2(), Vector2()]

func _input(event):
    if event is InputEventScreenTouch:
        positions[event.index] = event.position
        if event.index == 1:
            var zoom_amount = (positions[0] - positions[1]).length()

(I've not tested this though)

by (3,213 points)

Thank you for your help. Your reply is in alignment with the other reply :)

+1 vote
by (20,485 points)

Thank you for your reply. Unfortunately, even though I enabled "Emulate Touch From Mouse", the camera doesn't move when I click around the target. I'm not sure what's wrong. I did specify a target.

Make sure you don't have a Control node intercepting the mouse/touch events.

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.