This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

hi!
Recently tried to make on screen controls but I ran into an issue
I had four touch screen button with name BtUp, BtDown, BtRight and BtLeft. And I had connected their button_up and button_down to a script.
Script:

var down_pressed = false
var ev = InputEventAction.new()


func _process(delta):
    if down_pressed == true:
        print("down_pressed")
        ev.action = "ui_down"
        ev.pressed = true
        Input.parse_input_event(ev)

func _on_BtDown_button_down():
    down_pressed = true


func _on_BtDown_button_up():
    down_pressed = false

I had done the same for all the buttons but whenever I press and release any button then It only moves that way but don't stop.
It prints down_pressed as long I press the key.

Godot version 3.3
in Engine by (942 points)
edited by

1 Answer

0 votes
Best answer

You need to set

 down_pressed=false

in the _process() function

by (810 points)
selected by

It did not worked :(

Ah ok. I only tested it with mouse button. Maybe touch is different.

Any other solution?

Does this help? Seems to be doing what you are doing

https://www.youtube.com/watch?v=HLX0lfR7-08

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.