Simulate ui action

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

Hi, I want to move in the UI with Joypad axis but it’s bugged (ui_dir every frame when a stick is pressed)

I tryed to control that with something like :


But the game doesn’t detect that. So what I can do to press this action with code?
Sorry for my english and thanks in advance.

If you want to move the UI (or cursor) without it moving every frame, have a Timer count down a certain amount of time. For example, whenever the joypad is moved, use a Timer to count down 0.2 or 0.3 seconds. Once the Timer had stopped, allow the joypad to move the UI again.

Ertain | 2018-07-08 20:32

:bust_in_silhouette: Reply From: duke_meister

I’ve never done this, but I saw it in the manual. Don’t look at the details, just the way it’s done. I took it from here

var local_pos = Vector2(10, 20) # local to Control/Node2D
var ie =
ie.button_index = BUTTON_LEFT
ie.position = get_viewport_transform() * (get_global_transform() * local_pos)