I'm currently building an HTML5 game in Godot 3.5 for mobile. I'm using general Control
nodes with TouchScreenButton
children for UI Controls to pause the game and to toggle sound/music and I'd like to avoid touch events on those buttons propagating to the player input. Setting the mouse_filter
property to Stop
does the job on PC and Android, but on iOS (in my case on my iPad) pressing the buttons also triggers the player input event.
If anyone has come across a similar issues, I'd be grateful to know how you solved them.
For reference, here is the input handling code for the player character:
func _unhandled_input(event) -> void:
# if pressed:
if Input.is_mouse_button_pressed(1) and _can_trigger:
_charging = true
_local_event_touch_point = make_input_local(event).position
_touch_point = event.position
_target = _local_event_touch_point
_aiming_direction = position.direction_to(to_global(_target))
_charging_bar.set_rotation( _charging_bar_rect.position.angle_to_point((_target)) + PI )
# var grown_rect_charging = _charging_bar_rect.grow_individual(0,0,_charging_bar_rect.position.distance_to(_target),0)
_charging_bar.visible = true
if not event is InputEventMouseMotion and _can_trigger:
if not Input.is_mouse_button_pressed(1):
_charging_bar.visible = false
var projectile = _projectiles[_active_projectile]
_shoot(_aiming_direction, projectile, _shooting_speed)
_shooting_speed = 0
_charging = false
_can_trigger = false
(using both emulation from touch to mouse and vice versa)
I tried
- modifying the touch emulation settings
- adjusting
mouse_filter
- checking if my fat fingers are at fault ;)