Skip to content

Commit 55429c8

Browse files
committed
fix: attach touch controls to UI canvas
1 parent 661ff9f commit 55429c8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scripts/player.gd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ func _ready():
8484
# Initialize touch controls if on mobile
8585
if OS.has_feature("mobile") or OS.has_feature("web"):
8686
touch_controls = touch_controls_scene.instantiate()
87-
get_tree().root.add_child(touch_controls)
87+
var ui_root := get_tree().root.get_node_or_null("Node3D/UI")
88+
if ui_root:
89+
ui_root.add_child(touch_controls)
90+
else:
91+
get_tree().root.add_child(touch_controls)
8892
touch_controls.joystick_input.connect(_on_joystick_input)
8993

9094
# Get reference to pause menu from UI

0 commit comments

Comments
 (0)