Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Loading a map in segments

Discussion in 'Scripting' started by Kevinbreurken, Jan 24, 2017.

  1. Kevinbreurken

    Kevinbreurken

    Joined:
    Apr 1, 2015
    Posts:
    16
    I’m trying to make a grid based map. (64x64 chunks (each chunk is 20x20units) ) Each chunk is premade by me and loaded reference. I’ve already got the code to determine which chunks need to be loaded and unloaded. ( 5x5 chunks around the camera)

    As of now a chunk has a plane with 6.5k tris. At most 5 new chunks are loaded at the same time. But this results in a one second freeze with a 8.4MB GC Alloc.

    If i load them all at the start of the game. It removes the freezes during loading new chunks. But having all 4096 chunks and it’s content inactive sounds worse then instantiating them.

    Does anybody have any experience with creating these type of maps?
     
  2. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
  3. Kevinbreurken

    Kevinbreurken

    Joined:
    Apr 1, 2015
    Posts:
    16
    With instantiated during camera-movement i destroyed them. With all chunks loaded on start i disabled them.

    The result i'm trying to get is something like this overworld map of Oracle of Seasons. But instead in a 3D top down view.


    All of the chunks are built in 3DSmax and don't contain any voxels (imagine each chunk being a ProBuilder segment).
    Switching the renderer on and off is cheaper. But having each chunk already active in the scene results in 204k+ inactive GameObjects in the scene (64x64x50, 50 being the estimate of amount of objects a chunk wil contain)

    I don't know what Unity does with inactive GameObjects. They still take up memory so that's why i wanted to instantiate them during camera movement.
     
    Qusdrok likes this.
  4. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,749
  5. Qusdrok

    Qusdrok

    Joined:
    Jun 28, 2020
    Posts:
    24
    i hope you can see my answer, I have the same question with you, I hope you did it, and can you guide it to me?