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?
Edit:
Solved by instead of toggling the gravity on/off with gravity_space_override, I’m storing these
var default_gravity: float = 980
var default_gravity_direction: Vector2 = Vector2.DOWN
var default_gravity_point: bool = false
and toggling between the default/downward gravity and the alternate gravity that I want in the Area2D.

