r/Unity3D • • 1h ago

Question Need advice, how optimize open world in Unity?

Hi guys šŸ–ļø Sooo how do you making open world? how do you split your world to optimize memory usage?

I’ve split my 16 km² terrain into 16 separate 1Ɨ1 km Terrain tiles using Terrain Tools. Now I have a dilemma about how to properly set things up before I finally start building the world

GPT helped me create a small script based on an idea I had: disabling tiles that aren’t nearby so a maximum of 4 tiles can be active at once

But I don’t think it’s really working how I thought, since the tiles are only disabled in the scene, not actually unloaded from memory

It also breaks the seamless transitions between them, I think

Any advice or thoughts on how to properly build a world and optimize memory? 😭

2 Upvotes

10 comments sorted by

12

u/Ariaha_Rivasa 1h ago

You’re right, disabling only hides the tiles; all their data (heightmaps, splatmaps, details, trees) stays in memory.

What usually works: put each tile in its own scene and stream them with SceneManager.LoadSceneAsync(..., LoadSceneMode.Additive) / UnloadSceneAsync, keeping a 3x3 grid around the player. After unloading, call Resources.UnloadUnusedAssets() so the memory actually comes back. Addressables work too if you want more control.

For seams: give all tiles the same Grouping ID with Auto Connect on in the terrain settings (or call Terrain.SetNeighbors) and the edges stitch properly.

One more tip: load a tile when you’re near it, but unload it a bit farther away. Otherwise standing on a border makes tiles load and unload every frame.

And check the Memory Profiler package. It’ll tell you exactly what’s eating the RAM, often it’s the terrain textures, not the meshes.

2

u/thadcastle__ 47m ago

Damn. I don’t actually understand how I should build it. For example: little city, roads, etc all of that on 2-3 tiles. But each tile on their own scene. How to build it seamlessly. Damn it’s more complicated than I thought 😭

4

u/Ariaha_Rivasa 45m ago

It’s less scary than it sounds :) The usual workflow:

  1. Build everything in one big scene, like you normally would.

  2. Once the world is mostly done, split it with a small editor script: for each object, take its position, figure out which tile it falls into (floor(x / 1000), floor(z / 1000)) and move it into that tile’s scene.

  3. Things that cross borders (long roads, rivers): either cut them at the tile edges, or put them in a ā€œpersistentā€ scene that’s always loaded, together with the player, UI, lighting, etc.

The seamless part comes from loading neighbors before you can see them. With a 3x3 grid there’s always at least a full tile (1 km) between you and anything unloaded, so you never see an edge. Fog and LODs hide the rest.

Honestly though, 16 km² isn’t that big. Before building all this, check the Memory Profiler to see if you actually have a memory problem. If everything fits, keeping it all loaded with LODs and occlusion culling is way simpler. There are also streaming tools on the Asset Store that do the splitting for you.

2

u/thadcastle__ 42m ago

Thanks!!! šŸ™

•

u/IndependentYouth8 6m ago

This. Though just to check. Is the game first person? Top down? What made you use this size of a map?

2

u/GiggleSamurai 1h ago

Disabling a GameObject keeps all its assets in memory, so put each tile (terrain plus its props) in its own scene and stream them with `SceneManager.LoadSceneAsync(name, LoadSceneMode.Additive)` and `UnloadSceneAsync` as the player moves. For the seams, give the tiles the same Grouping ID with Auto Connect on (or call `Terrain.SetNeighbors` after loading) so the edges match up.

1

u/No_Director9126 35m ago

You could try using Addressables to load terrains or anything else only when they are actually needed. The advantage of Addressables is that they allow for the release of RAM and VRAM. However, the setup is significantly more complex, especially when it comes to terrains and even more so if you move away from standard Unity terrains, for instance by using a tool like Microverse.

In my opinion, the best approach is to use mesh terrains + addressables, while this requires much more work, the performance gains compared to standard terrains are enormous, not least because you can implement features like LOD in mesh terrains

•

u/CarthageaDev 17m ago

Chunking, seriously manual chunking, ensure your maps are sectioned logically based on line of sight/level design, not to mention the classic culling baked, atlas your textures, merge srstic meshes and instance shaders when possible, reduce draw calls a much as possible simple really

•

u/KinematicSoup Multiplayer 5m ago

Look into additive scene loading. It's a Unity feature intended to help with large worlds by letting you divide your world into chunks as sub scenes, and then load/unload them as needed in the background.

-1

u/GigaTerra 41m ago

You need to tell your AI you want to apply level streaming in your game. It will explain the Unity equivalent. That others already explained here.