-
Notifications
You must be signed in to change notification settings - Fork 4
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
Box2dPhysicsNodes and fixtures should still work in sub-scenes. #26
Comments
This seems to be the primary folly of using a node to represent the physics space. Godot doesn't have this issue because it uses a physics server singleton. Having the world as a singleton may be the only way to resolve this. We can keep Box2DWorld as a node to create spaces other than the singleton. I believe the code to look at is https://github.com/briansemrau/godot_box2d/blob/4.0/scene/2d/box2d_physics_body.cpp#L147 (as well as in Fixture and Joint) |
My initial guess at a solution would be to make a modification to look for the singleton world in case one is not found in the scene tree. |
I dunno, i'm not 100% sure about it. I'm not a huge fan of singletons, and think there's a chance we don't need the world to do body and fixture setup. We could also default to having at least a global world available at the root, if you never add another one. Going to investigate further, but you could be right. |
IIRC The 'real root' in godot, is kinda above what you see above the scene tree (there's kinda one global root that loads scenes underneath it). I think that's the case. If that is the case, we can keep the 'World' lookup code the same (traverse up the tree until you find a world) |
Alright, this should be working with #31 |
Does this issue include the scope of running sub-scenes, even if just for testing? The current PR seems to make things better in the editor, but is limited to that. |
If you run this sub-scene, however, it won't work, right? Because there is no b2world |
ya, that's correct. OK, i see what you are saying now. |
So hmm, i feel like that is OK. If users set things up like this they should know what they are doing. |
At least the warnings make it very clear. |
closing with #32 as followup to the discussion had |
during porting of my project, I discovered that obviously physics bodies and fixtures need to be supported in sub-scenes. i.e, the scene doesn't hold a world node, but is attached to another node which contains the world. In the screenshot below GameData scene is included in another scene (which contains the box2d world).
Going to investigate how to support this.
The text was updated successfully, but these errors were encountered: