Control Touchscreen Button Plugin requires Godot 4. It provides a touch button node identical to Godot's native TouchScreenButton2D, but designed to work within the Control node hierarchy instead of Node2D. This node is ideal for user interfaces and HUDs in mobile games.
- Implements a touch button as a
Controlnode. - Full support for touch events.
- Easy integration with Godot's UI system.
- Download or clone this repository into your Godot project.
- Copy the
addons/touchscreenbuttoncontrolfolder into your project'saddonsfolder. - Open your project in Godot.
- Go to
Project -> Project Settings -> Plugins. - Enable the
TouchScreenButtonControlplugin.
- In the Godot editor, add a new
TouchScreenButtonControlnode to your scene. - Configure the node's properties according to your needs.
The basis of my work was derived from code by the YouTube channel Mustache Games. This was my starting point to create and extend this idea into a plugin.
func press():
var event = InputEventAction.new()
event.action = input_action
event.pressed = true
Input.parse_input_event(event)
released = falseLater, I found that this solution did not work as the observers handling Input.get_vector do not manage this type of input.
Special thanks to Facundo Tkaczyk for helping me achieve this final approach.
func press():
var input_event: InputEvent = InputMap.action_get_events(input_action)[0]
input_event.pressed = true
Input.parse_input_event(input_event)
released = false