Skip to content

C# utility classes for Godot, handling pinch, twist, drag, etc. gestures in a uniform way.

License

Notifications You must be signed in to change notification settings

MatthijsMud/Godot-Gestures

Repository files navigation

Godot Gestures (C#)

This project relies on System.Reactive If not using this project's C# file

$ dotnet add package System.Reactive

Modes

Touch

Open the project settings: Project » Project Settings…, and head to the AutoLoad tab.

When selecting the Path to the "singleton", it is suggested to use the scene addons/gestures/TouchGestureController.tscn (assuming the default path) rather than the script. Both instances should work just fine, but using the scene allows for modifying the settings from the inspector (by editing the scene in question).

This controller provides no useful interface for other classes; instead passing the events to the Input singleton. As such, Node Name is of little relevance.

Emulation

Some devices do not have a means to input any of the Supported gestures. Be it due to not having a touch screen, or only supporting a single touch. Development PC's are more prone to this limitation, which can be inconvenient.

To alleviate this issue somewhat, this project provides alternative means to input certain gestures; Instead relying on mouse clicks/movements, scrolling and some keyboard presses to modify the gestures on the fly.

⚠️ Warning: These emulated gestures aren't a perfect replacement for the ones based on touches. They should however make it possible for more easily creating cross-platform applications with different input methods.

Supported gestures

Tap

One blob (representing a finger touching the screen) that disappears shortly after appearing, demonstrating the "tap" gesture.

Gesture where one finger makes contact with the screen for a very short time, with little movement. This gesture is typically used for selecting things or clicking on buttons.

Details

InputEventScreenTap

Property Description
Index Finger which triggered this touch event.
Position Last known position of the finger that triggered this event before it no longer touched the screen.

Long press

One stationary blob (representing a finger touching the screen) that disappears about 1 second after appearing, demonstrating the "tap" gesture.

InputEventScreen

Property Description
Index Finger which triggered this touch event.
Position Position of the finger at the moment this event was triggered.

Drag

One blob (representing fingers touching the screen) moving up and down in usison, demonstrating the "drag" gesture.

Property Description
Index Finger which triggered this touch event.
Position Position of the finger that triggered
Delta Indicates the movement of the finger relative to the previous frame.

Multi-drag

Two blobs (representing fingers touching the screen) moving up and down in usison, demonstrating the "multi-drag" gesture.

Gesture where two or more fingers all move in the same general direction. This gesture is typically used in contexts where at least two types of actions are associated with a drag gesture, where the number of fingers is used to determine which action to perform.

For example: A drawing application that supports zooming in and out might also want to support panning the canvas. Both drawing and panning would typically involve the dragging gesture.

Property Description
Position Center of the fingers involved in the gesture.
Delta Indicates the movement of the center relative to the previous frame.

Pinch

Two blobs (representing fingers touching the screen) moving towards and away from each other, demonstrating the "pinch" gesture.

Gesture where two or more fingers either move toward or away from one another. This gesture is typically used for zooming in/out.

InputEventScreenPinch

Property Description
Position Center of the fingers involved in the gesture.
Factor Positive numbers indicate the touch positions move away from eachother; negative numbers indicate they move toward eachother.

Twist

Two blobs (representing fingers touching the screen) moving in circles around a single point, demonstrating the "twist" gesture.

Gesture where two or more fingers move in "circles" around a point. This gesture is typically used for rotating a canvas, or twisting knobs.

InputEventScreenTwist

Property Description
Position Center of the fingers involved in the gesture.
Angle Rotation (in radians)

About

C# utility classes for Godot, handling pinch, twist, drag, etc. gestures in a uniform way.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages