Help w/ Area2D and multiple on_body_entered()'s being triggered

https://lemmy.world/post/43648235

Help w/ Area2D and multiple on_body_entered()'s being triggered - Lemmy.World

Essentially, I have some Area2Ds in which I’m changing the direction of gravity. I only want this to happen if the player has enough speed. So, I was checking for that condition and setting gravity_space_override = Area2D.SPACE_OVERRIDE_DISABLED when the player was too slow. That’s when I ran in to this issue… Here is a minimal amount of code to reproduce my issue. On an Area2D, when my player enters it: func _on_body_entered(body: Node2D) -> void: if body is Player: print('enter') gravity_space_override = Area2D.SPACE_OVERRIDE_DISABLED gravity_space_override = Area2D.SPACE_OVERRIDE_REPLACE I see “enter” printed multiple times. If I comment out the last two lines, “enter” is printed once, as I’d expect. How might I modify gravity_space_override without having the body_entered signal firing off again?