+2 votes

I making the touch controls, and I need that when the touch enters the area (Area2D for example) or being pressed in the area, then the variable is set to true. And when the touch leaves the area or being released, it is set to false. How can i do that? Thanks in advance!

I tried this, but it doesn't work when touch enters or leaves the area, it works only when touch being pressed or released within the area:

func _on_Area2D_input_event( viewport, event, shape_idx ):
if event.type == InputEvent.SCREEN_TOUCH:
    if event.is_pressed():
        print("Touch inside the area")
    else:
        print("Touch outside the area")
in Engine by (26 points)
edited by

Probably OK, the examples have validation on Area2D github
Does not work with CanvasLayer

Please log in or register to answer this question.

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.