Search Unity

How can I create a large, dynamic map without putting millions of gameobjects into the scene?

Discussion in 'World Building' started by AidanofVT, Sep 21, 2020.

  1. AidanofVT

    AidanofVT

    Joined:
    Nov 10, 2019
    Posts:
    104
    My goal is to make a large map covered in grass which can be cut and regrow. If the map had a fidelity of just 1000x1000 grass units, that would be a million things in the scene that have to be updated. And I want more than that. I understand that I can lighten the load by making the updating of these grass patches done by one central script that only updates each grass patch occasionally, but I'm concerned that that won't be enough.

    I guess what I asking is: is Unity clever enough to deal with, say, a hundred million objects, if those objects are just a sprite renderer, a 2d collider, and a little script with no update method?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Simple answer: No.

    Less simple answer: Usually no. You could probably do it with the new Jobs/Entity system, but even then, you probably shouldn't. The thing you need to embrace is faking it. When you look at a scene in a AAA video game that appears to have thousands of trees, blades of grass, etc.... that is not what is actually there. 90% of what you see is faked. It's all smoke and mirrors.

    So you should ask yourself, what are the right smoke and mirrors for this situation? Perhaps you should draw the grass with something like DrawMeshInstanced? Maybe you only draw the nearby tufts of grass, and use a big ol' textured plane for areas of ground too far away to see grass clearly on? Maybe you can limit the camera angles so that the user can never look that far away anyway? Maybe every hectare of land is just one mesh with a bunch of grass triangles, which you modify dynamically as the grass is cut?
     
  3. AidanofVT

    AidanofVT

    Joined:
    Nov 10, 2019
    Posts:
    104
    @JoeStrout Thanks again. I was already thinking about these sorts of solutions before I posted the thread. Ignoring the off-screen entities should be pretty easy, since this is a top-down perspective game, but I was hoping to have a strategic-zoom feature. Maybe I'll have to abandon that, or, if there was some way to make tilemaps at runtime, maybe I could have some large tilemaps that just get replaced periodically as visuals need to be updated. Do you know if that's possible?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I'm not sure, I think I maybe used the Tilemap feature about once several years ago. :p