+2 votes

Hello,

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!

in Engine by (38 points)

1 Answer

+1 vote

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."

and

"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."

by (129 points)

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!

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.

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.