More than one physics environment?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By z80


I’d like to port my project to Godot. In order to do that I need to make a few physics environments (or whole scenes) which do not interact with each other. Is it possible?

(In the original project I just create a few instances of Bullet DynamicsWorld class. But I don’t see any obvious way of doing that in Godot.)

I’d appreciate any advice!

:bust_in_silhouette: Reply From: aa

I haven’t actually done any testing on this, but by reading the following excerpts from the documentation I assume this is possible:

A World class is defined as a

Class that has everything pertaining to a world. A physics space, a visual scenario and a sound space. Spatial nodes register their resources into the current world.

A Viewport (of which you can have several) contains a World instance. In 3D

“A World can be set in a Viewport using the “world” property, and that will separate all children nodes of that Viewport from interacting with the parent Viewport’s World.”


“For 2D, each Viewport always contains its own World2D. This suffices in most cases, but in case sharing them may be desired, it is possible to do so by setting the Viewport’s World2D manually.”

Thank you for the reply! I appreciate it!

I’ve read the World description. What confuses me in World description a little bit is how to actually use that. I can see that any Spatial derivative has get_world() method. But I personally have troubles finding the way to actually create one instead of using the default one.

Is there any example for that?

Thank you again!

z80 | 2020-01-04 06:35

I don’t know how you would go about using a World instance on it’s own, someone with a better understanding of the engine than me would have to chime in on that one.

But couldn’t you just create several Viewport nodes (who will then instance worlds on their own?) Then you’d have separate hierarchies you could attach your Spatials to. As far as I know you don’t have to actually display viewports.

Not at all sure if this is the best or most efficient way of going about this, though.

aa | 2020-01-04 06:46

Thank you! This makes sense for me. Even though it doesn’t look like the straightest way of doing things but at least it is worth to try that.

z80 | 2020-01-04 20:28