2
\$\begingroup\$

TLDR: What are limitations on how many objects a single prefab can handle safely? keeping in mind that I could potentially have almost a 100 of these

I am busy creating a system to essentially load the game world in chunks as the player moves. This means that every single object in the world will be streamed into the game through script when needed(still designed in the editor, impossible otherwise) The problem I am having is with methods to store and load objects.

I have looked at everything I could think of or get information on. After researching all the methods I found, I started thinking that prefabs is the best solution since it can live anywhere in the project(unlike streaming assets folder, which is also not recommended for many assets, let alone every single asset). Creating Game Objects at runtime is not as easy once GO's get complex with components and settings, also I assume the performance hit from creating GO's this way is worse than using an existing prefab.

So my question is if prefabs can handle massive amounts of objects(lets say 1000) safely? testing this is hard because i would have a prefab(or a few) for each tile that gets loaded.

\$\endgroup\$
2
  • \$\begingroup\$ This sounds more like a case for additive scene loading than for prefabs. In any case, what evidence have you gathered that leads you to suspect prefabs introduce any new limitation in the realm of 1000s of objects? \$\endgroup\$
    – DMGregory
    Commented Sep 5, 2019 at 20:09
  • \$\begingroup\$ OMG, additive scene loading was the missing component. Literally the last piece of my current puzzle. I seem to have completely missed the fact that the scene workflow has improved so much. Also regarding the prefab limit, I did not say it could be in the realm of 1000 objects, I said i could have 1 or more prefabs each with a 1000 objects for each tile, with possibly a 100 tiles. It was just a concern related to scaling. Its hard to find info or guestimate these things when working with tech I did not write. \$\endgroup\$
    – Pusche
    Commented Sep 6, 2019 at 20:37

1 Answer 1

1
\$\begingroup\$

Prefabs are just a useful way of storing gameobjects that are going to be repeated. As a result you can have just as many prefabs as gameobjects, in other words as many as you need.

There is, of course, a computational limitation. If each prefab is running its own complex AI and has a complicated hit box and your spawning 1000s it could cause a real problem for even beefy computers. In most cases though just having a system that spawns many prefabs as background tiles to make up the floor of a 2d world or the like would not be any problem.

With that said creating that many gameobjects is a very inefficient way of handeling processing power. I would look into meshes and mesh chunks as an alternate solution if you run into any computational issues

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .