-
-
Notifications
You must be signed in to change notification settings - Fork 23.4k
Fix StaticBody2D not triggering collisions when waking up
#111880
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
base: master
Are you sure you want to change the base?
Conversation
StaticBody2D not triggering collisions when waking up
|
Does this actually fix the case when changing the layers only? This seems to fix just waking up the body |
088a840 to
829da14
Compare
|
As in description, current physics engine does not support active The straight way to fix this issue is allow If we dont want fixing issue this way, maybe we need add additional logic for |
|
No what I'm asking is: |
|
I can get your point, I will test for only triggering adding active_list without set active. |
|
The test project from the issue should confirm if this solves it! |
829da14 to
b39d44e
Compare
|
I tested only add wakeup.webm |
Issue Description
Because
StaticBody2Dcannot be set active and cannot be add toactive_list. So theStaticBody2Dwont trigger actively collision itself.godot/modules/godot_physics_2d/godot_body_2d.h
Lines 287 to 292 in f50d7fa
godot/modules/godot_physics_2d/godot_body_2d.cpp
Lines 140 to 146 in f50d7fa
Please notice this PR is just a demo to fix relevant issue. I am not sure it is the correct solution. Maybe current behavior is expected.
Explaination
In PhysicsServer2D, it decides which body need be detected collision depends on
get_active_body_list()andget_moved_area_list().godot/modules/godot_physics_2d/godot_step_2d.cpp
Line 139 in 9cd297b
godot/modules/godot_physics_2d/godot_step_2d.cpp
Line 170 in 9cd297b
If there is no
active_listormoved_area, the collision detection wont execute.When we changed
layerormask, it invoke parent classGodotCollisionBody2D. It is the parent class ofGodotBody2DandGodotArea2D. ThenGodotArea2Dadded itself tomoved_area_list, so next iteration will detect collision. ButGodotBody2Dwont add static body toactive_list, so it can only wait other body to trigger collision detection.It looks like
StaticBody2Dwont participate withintegrate_forceorintegrate_velocity, maybe only add it toactive_listis safe. But still need test for confirming.