How to map/assign an InputMap action to a Button(onscreen s/w btn; not a kbd key) ?

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

How do I assign or map an InputMap action to an onscreen software button instead of using actual hardware keys from keyboard to perform the intended action (somewhat like what is possible with TouchScreenButton).

Is it possible in Godot ?

:bust_in_silhouette: Reply From: yrtv

It is not recommended way in godot for touch input. Instead, feed action back to the engine then you processed your input.

From Using InputEvent — Godot Engine (stable) documentation in English

Alternatively, it may be desired to supply the game back with an
action from the game code (a good example of this is detecting

But if you want you can use TouchScreenButton — Godot Engine (stable) documentation in English

So there’s no way I can do as I want?

devAS | 2021-02-11 11:50

You can. See second link. But it’s a very simple button.
If you need something more complex, you will have to do it yourself. See first link.

yrtv | 2021-02-11 21:38

I already tried the TouchScreenButton but it doesn’t show up. Why?

devAS | 2021-02-12 11:45

Assign action in inspector window of TouchScreenButton.

yrtv | 2021-02-13 21:17

Sorry for being this late, but I had my exams an have too, so I’d be less active in the forum.

Of course I did that, but it doesn’t seem to work. Any idea why?

devAS | 2021-04-04 15:50

Doesn’t work in what way exactly? Try assigning action from code with TouchScreenButton.set_action()

yrtv | 2021-04-04 18:03

Sorry if I’m too annoying but I’m new to this - your engine and gamedev in itself.
It doesn’t work in the way that the button is not getting the action assigned to itself, don’t know why.
This is the code I’m using for it:

func _ready():

Is it alright?

devAS | 2021-04-05 10:22

Sorry Sir,
I troubled you a lot, but it was that I had actually commented a code snippet in another script which I didn’t just see.
That was all causing the problem.
Sorry once again and Thanks a lot for your help :slight_smile:

devAS | 2021-04-05 10:40