Search Unity

Massive arrays, masses of low-poly objects

Discussion in 'Editor & General Support' started by Morgan, Jul 22, 2006.

  1. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    I'm thinking about building a scene on the fly in a "Lego" kind of a way, from prefabs. Basically like flying through a city where every building is a random stack of several blocks.

    I'm thinking big: like 1000 buildings with around 6 prefabs each. They'd be simple: 50 to 500 polys, average 200 polys. Maybe 50 to 100 prefabs in the "library" that gets drawn from, and multiple different textures being randomly selected too. And each prefab would be a mesh collider as well.

    So is 6000 instances/colliders, with an assortment of textures just asking for trouble?

    Three things that help:

    1) The prefabs would never move once they've been placed.

    2) They would NOT all be VISIBLE at once: I intend to arrange things so that your view is constrained to maybe 5-15 buildings at once. (In other words no long open streets to look down.) About a million polys total, BUT only 10 to 20,000 in view at once.

    3) I'm not targeting low-end machines. (This is a playground for something I'd like to do "someday," nothing I'll finish soon.)


    Along with the prefabs, my script for laying out the "city" and controlling enemies within it would need a large array. I'm thinking maybe a 10x10x10 array, and each element IN the array would be ANOTHER 10x10x10 array. (Can you nest arrays like that in Unity without manually declaring every one?)

    That's a million data points. Anything I should be warned of re arrays of that complexity? (I know there would be a delay as the data is fed INTO the array, but it would only happen once--the data would not change mid-game, it would just be there for the enemies to "look up" tactics in.)


    Thanks in advance!
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Basically having 6000 objects is not a very good idea. What you really want to do is combine your objects on the fly into larger combined objects that have at least 1500-2000 triangles each.

    Using the mesh interface you can easily combine objects. I'll also post a script that combines all meshes that are transform children at startup soon.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    That would be fantastic...I was just about to ask a similar question, actually.

    ("Unity support: so good, we reply before you even ask." ;) )

    --Eric
     
  4. Morgan

    Morgan

    Joined:
    May 21, 2006
    Posts:
    1,223
    Great! I didn't even think of that. Would each mesh in the "combo" retain its own unique texture?
     
  5. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Either it'd share a texture (just have different things have their own little spot in the UV map) or his script would have to generate multiple materials, in which your performance gains would be lost. (Each material is a rendering pass)

    -Jon