0 votes

So i have a game, and in it there is a touchscreen button, i dont know how to know if the touch screen button has been pressed?

heres my code:

extends TouchScreenButton

var motion = Vector2()
func _physics_process(_delta):
    if (is_pressed()):


its not printing when i touch it in run.

Godot version 3.3
in Engine by (37 points)

That should work, are you sure your identation is correct? Because on the code sample you posted it's wrong.

Also, are you running this on your computer or on an actual phone? Because clicking a touchscreen button with a mouse won't press it. You'll need to go into project settings and enable emulate touch from mouse.

Nevermind, i figured out that in the action property of touchscreenbutton, i can set an input to trigger, and from a script i can check if the input has been triggered and do something. also i did put emulate touch from mouse.

Oh alright then!

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 Frequently asked questions and 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 [email protected] with your username.