Half-Screen Buttons

Godot Version


Half Screen Buttons

I can’t disclose many details on my game, but it’s a 2D auto-runner with 2 buttons - a jump and an attack.

Is there a way to have touch inputs be split by their x coordinates on a UI layer or smth, or would I have to code a system which does that manually? Should I instead just upscale/reposition 2 giant TouchScreenButtons to cover half the screen each and call it a day? If there’s anything better, like a viewport-based boundary object that’d help with this, please let me know that, too!

I also want both inputs to have different combos with each other (IE holding vs tapping vs double tapping attack button doing 3 different things).

You could use Node._unhandled_input() and listen for InputEventScreenTouch and InputEventScreenDrag events. Check their x position against the viewport half x size and emit the correct signal.

For example:

extends Node

signal left_side_input(pressed:bool)
signal right_side_input(pressed:bool)

func _unhandled_input(event: InputEvent) -> void:
	if event is InputEventScreenTouch:
		var size = get_viewport().size
		if event.position.x < size.x / 2.0:

You can make it as complex as you need.

Thank you for the info and the template! I’ll be sure to research further and tinker with this template a lot.