r/godot•
Jucamia

Need help getting a variable to change it's value when an Area2D that spawns in crosses the player

help me

my variable is this

onready var gate_score = randi_range(0, 10)

I have a global variable for a score that changes depending on the players mouse clicks

When an area 2d spawns in (every 5 seconds) it rushes towards the player. Player must have a socre that matches the gate_score

For some reason, as I learned through the print on the output menu, multiple gate_score are being activated and lingering at once. I've tried despawing these Area2D's, I've grouped the hitboxes thinking maybe my platforms were in the way, etc.

Simply put, I'd like the gate_score to pick it's points, stick with it, and reset it only once the Area2D has passed the player. But it seems to have multiple gate_score happening at once

Any tips or help? I've been on this all day, about to call it a night, so apologies if I don't get back swiftly. Thank you

Posted Jun 29, 2026, 11:31 PM UTC

36
Loading comments…