Skip to content

Repository files navigation

Godot Plugin: Control Touchscreen Button

Plugin Icon

Description

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.

Features

  • Implements a touch button as a Control node.
  • Full support for touch events.
  • Easy integration with Godot's UI system.

Installation

  1. Download or clone this repository into your Godot project.
  2. Copy the addons/touchscreenbuttoncontrol folder into your project's addons folder.
  3. Open your project in Godot.
  4. Go to Project -> Project Settings -> Plugins.
  5. Enable the TouchScreenButtonControl plugin.

Usage

  1. In the Godot editor, add a new TouchScreenButtonControl node to your scene.
  2. Configure the node's properties according to your needs.

Conflicts and Acknowledgments

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 = false

Later, 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

Author

Matata.exe

About

A Control Node version to TouchScreenButton2D

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages