this post was submitted on 27 Feb 2026
8 points (100.0% liked)

Godot

7411 readers
20 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
 

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.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here