+1 vote

hi!
I have a Texture Button and i want to execute this code as long as the button is pressed

var ev = InputEventAction.new()
ev.action = "move_left"
ev.pressed = true
Input.parse_input_event(ev)
Godot version 3.3
in Engine by (942 points)

1 Answer

0 votes
Best answer

You could use signals to connect from the texture button to the script, you can connect the button pressed and button release, they make it so when the button is pressed it makes a var true and when it is released it sets it to false and then makes
a while loop (or any other thing) to run when that var is true

var pressed = false
func _on_button_up():
    pressed = false
func _on_button_down():
    pressed = true
func _process(_delta):
   while pressed = true: #or if
     #Thing you want to run

Though this is a solution, I am going to assume that my way is not the most efficient way.

by (72 points)
selected by

it worked but button_up did not worked
it just continued to execute the code
Still 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 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.