On screen controls

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Help me please

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.

:bust_in_silhouette: Reply From: wyattb

You need to set

 down_pressed=false

in the _process() function

It did not worked :frowning:

Help me please | 2021-06-16 07:18

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

wyattb | 2021-06-16 15:04

Any other solution?

Help me please | 2021-06-17 06:07

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

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

wyattb | 2021-06-17 13:08