Mobile version variable not being set correctly

Godot Version

4.6.1.stable

Question

Hey guys, so I’m trying to make a minigame for my mobile pet sim game where you have to clean your pet by swiping on its dirty areas to clean them, gradually making the filth disappear by decrementing the alpha value of the modulate.

However, for some reason, the game detects my input and successfully goes down the code path that activates the bubble emitter and which SHOULD turn my scrubbing variable to true, however this never happens. On computer, it works just fine and sets the value as it should, but in the mobile export, the variable somehow doesn’t get set.

extends Area2D

var has_mouse := false
var scrubbing := false

signal finished

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	randomize_filth()

# Set a random filth texture to be applied
func randomize_filth()->void:
	$Sprite2D.texture.region.position = Vector2(randi_range(0,4)*16,0)

func _input(event: InputEvent) -> void:
	if has_mouse:
		if event is InputEventMouseMotion:
			$"../../Bubbles".emitting = true
			scrubbing = true
		else:
			scrubbing = false

func _on_mouse_entered() -> void:
	has_mouse = true


func _on_mouse_exited() -> void:
	$"../../Bubbles".emitting = false
	has_mouse = false

func _process(delta: float) -> void:
	if scrubbing:
		modulate.a -= .8*delta
		modulate.a = clamp(modulate.a,0,1)
	if modulate.a == 0:
		finished.emit()
		queue_free()
	scrubbing = false

Can you explain better what you are seeing happen versus what you expect to happen?

The bubbles emits, but scrubbing appears to be false?

If so maybe it’s because more events may be occurring on mobile, touch events are not mouse motion events they may trigger the else and set scrubbing to false before process can run and check it’s value. You likely do not need this else branch in general.

Pfft duh lol I didn’t realize that, thank you. I’ll try this

As was said, Godot emulates mouse with you ch, but not motion. You could just add a touch event check or something.