0 votes

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 ?

Godot version 3.2.3
in Engine by (86 points)

1 Answer

0 votes
Best answer

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

From https://docs.godotengine.org/en/stable/tutorials/inputs/inputevent.html

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

But if you want you can use https://docs.godotengine.org/en/stable/classes/class_touchscreenbutton.html#class-touchscreenbutton-property-action

by (538 points)
selected by

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

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.

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

Assign action in inspector window of TouchScreenButton.

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?

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

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():
    $Controls/btn_left.set_action("left")
    $Controls/btn_right.set_action("right")

Is it alright?

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 :)

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 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 webmaster@godotengine.org with your username.