Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bullet] Inconsistent generation of Area body_entered/body_exited signals #22889

Closed
Tracked by #45022
muiroc opened this issue Oct 9, 2018 · 6 comments · Fixed by #42306
Closed
Tracked by #45022

[Bullet] Inconsistent generation of Area body_entered/body_exited signals #22889

muiroc opened this issue Oct 9, 2018 · 6 comments · Fixed by #42306

Comments

@muiroc
Copy link
Contributor

muiroc commented Oct 9, 2018

Godot version:
0063ba9

EDIT:
Partially fixed by #25180 see comment below

Issue description:
Area entered/exited signal appears invalid, compared to GodotPhysics

StaticBody enters an Area, a body_exited is generated right after a body_entered.

KinematicBody same thing, as soon as it stops moving.

RigidBody looks like it works ok, maybe because its always moving (in the sample)

In godotphysics disabling a shape doesnt trigger body_exited

Steps to reproduce:
See sample project:

  • move the blue "character" with arrows keys
  • the button list on the right enables/disables the collision shapes
  • check the console messages
  • try the same with GodotPhysics

Minimal reproduction project:
bug_area_exit.zip

Note
Other stuff observed in the sample, outside the scope of the Issue:

  • I mentioned in another issue that this problem was also in godotphysics but looks like its working ok
  • sometimes the initial rigidbody velocity setted in editor doesn't get applied and the ball was "stuck in air" until something interacted with it (this also happened in other projects but i can't reliably repro it)
  • the character now pushes the rigidbody, even with infinite_inertia==false, but i'm pretty sure it didnt before, while creating the sample?! feel free to disregard this lol
  • Made that overly complex sample... but forgot to test Area vs Area signals...
@groud groud added this to the 3.1 milestone Oct 10, 2018
@AndreaCatania AndreaCatania self-assigned this Dec 3, 2018
@muiroc
Copy link
Contributor Author

muiroc commented Jan 21, 2019

Partially fixed by #25180

Correctly, now the exited signal is not called just as soon the body stops moving, while overlapping.

The remaining issue is that when the blue character overlaps the green area, if you disable the area's collision shapes, the exited/entered signals are not called (BOTH in godotphysics and bullet)

@akien-mga
Copy link
Member

The remaining issue is that when the blue character overlaps the green area, if you disable the area's collision shapes, the exited/entered signals are not called (BOTH in godotphysics and bullet)

Tested in the current master branch, and it seems like the exitered and entered signals are properly called when you disable/enable the collision shapes, but only once the character moves, thus updating the collision checks. I'd tend to say that it's OK as is, WDYT?

@muiroc
Copy link
Contributor Author

muiroc commented Jan 9, 2020

The current behavior is kinda unintuitive, but technically understandable

For example, sleeping rigidbodies are behaving similarly: the callbacks are not called until they wake

So we could think of a KinematicBody that is not move_and_colliding as if it was in a "sleeping" state
Nothing a little documentation can't solve

Still, Godot is about usability and intuitiveness: if I were a beginner I would expect signals to be fired,
even when my characters and movers are not moving, since I see them standing in the right spot

I guess its better to close this, and later formalize all the expected physics behaviors for the planned physics rewrite

@akien-mga
Copy link
Member

akien-mga commented Jan 9, 2020

According to @reduz this sounds like a bug more than intended design:

14:33 <Akien> reduz: see https://github.com/godotengine/godot/issues/22889#issuecomment-572446215 - Currently when two physics bodies overlap, and then you remove one of the collision shapes, the `body_exited` signal is not emitted until you attempt to move/change the physics state (even not on the next physics tick).
14:33 <Akien> Is that intended?
14:33 <Akien> Same with `body_entered` if you teleport a shape on top of an Area
14:34 <Akien> I have the feeling it's "normal" and just a bit annoying, but we should ensure it's well documented.
14:43 <reduz> thats odd, if collision is disabled it should trigger it almost immediately
14:44 <reduz> well, at least in the next physics iteration

@akien-mga
Copy link
Member

For the reference, since it's similar I checked if #33615 fixes this issue, but it doesn't appear to.

@muiroc
Copy link
Contributor Author

muiroc commented Jan 16, 2020

Just an hint: adding this line

isTransformChanged = true;

for example before this line

shapes.write[p_index].active = !p_disabled;

seems to fix the issue in bullet, probably something about this condition

if (!area->is_transform_changed() && !otherObject->is_transform_changed()) {

But I'm not sure which is the correct place to set isTransformChanged, or if it needs another dirty state flag

@akien-mga akien-mga modified the milestones: 3.2, 4.0 Jan 18, 2020
@pouleyKetchoupp pouleyKetchoupp changed the title Inconsistent generation of Area body_entered/body_exited signals [Bullet] Inconsistent generation of Area body_entered/body_exited signals Jan 16, 2021
@akien-mga akien-mga modified the milestones: 4.0, 3.5 May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants