Simple Quick Question About "InputEventScreenTouch" And "InputEventScreenDrag"

Godot Version

v4.6.2.stable.official [71f334935] - CachyOS Linux (Arch Linux based rolling release)

Question

Hi,

Would an “InputEventScreenTouch” always occur before an “InputEventScreenDrag”?
This is in reference to the desktop HTML5 Web build running on Android Chrome mobile.
Let us know, thanks!

HI ,

In Godot, the triggering order for touch interactions is: first InputEventScreenTouch, then InputEventScreenDrag.

Core logic and event flow

  • Touch press: When a finger touches the screen, an InputEventScreenTouch event with pressed == true is triggered first.

  • Touch drag: When the finger moves on the screen, InputEventScreenDrag events are continuously triggered, containing relative displacement (relative) and velocity (velocity) information.

  • Touch release: When the finger leaves the screen, an InputEventScreenTouch event with pressed == false is triggered.

I checked the docs; there’s no detailed explanation, but this is my understanding.

That is what we thought…

We have an issue with our game running on Android Chrome mobile:
If the user presses the screen and drags their finger across horizontally, multiple tiles are selected.
Not sure how to stop this…
(HTML5 desktop works 100% perfectly, just trying to get Android working properly now)

Relevant code is here on GitHub:
https://github.com/savantsavior/numbersfall/blob/main/project_numbersfall/InputCore.gd#L400

You can see this problem occurring on your Android Chrome mobile device by photographing below QR Code: (runs in browser, nothing to install)

Not sure this will work, but below is the URL link to play on Android Chrome mobile:

https://teamjezxlee.itch.io/numbersfall

You’re still using an LLM to code, aren’t you? Try just having touches emulate the mouse in the project settings. It’ll simplify your code, and likely solve your problems.

Hi,

I have both of those set to true in the project settings.
I don’t remember changing those before.

1 Like

I fixed it with below changes:

if (event is InputEventScreenTouch and event.is_pressed() == true):
	MouseButtonLeftPressed = true
	MouseScreenX = event.position.x
	MouseScreenY = event.position.y
	touchDetected = true
elif (event is InputEventScreenDrag):
	TouchDragDetected = true
	touchDetected = true
elif (TouchDragDetected == true):
	TouchDragDetected = false
	MouseButtonLeftPressed = true
	MouseScreenX = event.position.x
	MouseScreenY = event.position.y
2 Likes