Worlds
Last updated
Last updated
A World is a core part of a HYTOPIA game's lifecycle. You can think of a world as a container for all controls related to gameplay - audio, entities, lighting, physics, chunk terrain, tick loop, and more.
When you start your server, a default world is automatically created and provided for you to use. This world houses everything related to its own gameplay.
Creating additional world instances allows you to create completely isolated game world instances within your server. These instances exist in the same physical server instance. If you've played games like Minecraft, you can think of multiple world instances in a similar way to how Minecraft seperates The Overworld, The Nether, and The End worlds.
By default, players will automatically join into the default world when they join your game, but you can at any point in time join them to another World instance within your server through the player.joinWorld()
method, documented in .
In nearly all cases, you won't need to use any other world instances besides the default one returned in the callback of startServer(world => {})
.
Using additional world instances beyond the default world may only make sense in the following situations.
Your game needs to explicitly isolate its physics simulations where isolated world instances could achieve this, since each world runs its own physics simulation.
Your game needs control of environment lighting and visuals in a way that can't be done with a single world. Such as if your game has an overworld with sunny lighting, but also requires another world in "outer space" setting where no lighting, or completely different environmental lighting is required.
For now, we strongly recommend you isolate gameplay to a single world in most cases unless you know what you're doing.
A World instance exposes all of the managers and various functionality required to control game behavior.
You can find the most up to date list of available managers as properties of a World instance in the World API Reference here.
You can change the skybox of your world by adding cubemap images to an assets/cubemaps/skybox
folder in your project.
This assets/cubemaps/skybox
folder should include the following 6 images to use for the skybox.
+x.png
+y.png
+z.png
-x.png
-y.png
-z.png
These 6 images will be used for the 6 faces of the skybox on their appropriately named axes.
If no cubemap is provided by you in a assets/cubemaps/skybox
folder that you create, then the default skybox will be used.
The World class is constantly evolving. You Can find the latest World API Reference here.
If there are features that we don't currently support for Worlds that you'd like to see added to the HYTOPIA SDK, you can submit a feature request here.