Fix body leaving area gravity influence

This commit is contained in:
Occalepsus
2023-10-05 13:46:10 +02:00
parent 9d1cbab1c4
commit 492f1c2406
4 changed files with 15 additions and 3 deletions

View File

@@ -66,6 +66,7 @@ bool GodotAreaPair2D::pre_solve(real_t p_step) {
if (colliding) {
if (has_space_override) {
body_has_attached_area = true;
body->add_area(area);
}
@@ -74,6 +75,7 @@ bool GodotAreaPair2D::pre_solve(real_t p_step) {
}
} else {
if (has_space_override) {
body_has_attached_area = false;
body->remove_area(area);
}
@@ -103,7 +105,8 @@ GodotAreaPair2D::GodotAreaPair2D(GodotBody2D *p_body, int p_body_shape, GodotAre
GodotAreaPair2D::~GodotAreaPair2D() {
if (colliding) {
if (has_space_override) {
if (body_has_attached_area) {
body_has_attached_area = false;
body->remove_area(area);
}
if (area->has_monitor_callback()) {

View File

@@ -43,6 +43,7 @@ class GodotAreaPair2D : public GodotConstraint2D {
bool colliding = false;
bool has_space_override = false;
bool process_collision = false;
bool body_has_attached_area = false;
public:
virtual bool setup(real_t p_step) override;