0
\$\begingroup\$

I managed to have a basic map generation algorhytm, but now it needs some content.

I generate abstract map data, which then will be used to build the map itself.

When I want to generate monsters, chests, entrances, etc, I have a prefab, and I will determine it's placement, then register it in the mapdata.

The problem is that I want to configure them as well, like affixes, stats, or where those entrances lead, etc. But the component is only available after the map is built. At generation I have only the prefab, so I have to transfer the generated configuration to the map builder somehow.

If I could clone the prefab, modify the clone's values and store that prefab.. . that would be great. But I can only instantiate prefabs, and I can't clone them without making a new asset.

\$\endgroup\$
1
\$\begingroup\$

You can simply Instantiate the prefab, disable it, modif it, and keep it as a reference.

Once you need it, simply call Instantiate on the disabled gameobject, and use the result.

\$\endgroup\$
  • \$\begingroup\$ Instantiating GameObjects wouldn't cause some performance issues during the generation? And then during map building they all have to be deleted. \$\endgroup\$ – Tudvari Jan 24 at 7:26
  • \$\begingroup\$ Unless you're instantiating thousands of them per second, the performance difference will be minimal. If you are, then you need to reuse the same gameobjects as best you can. Of course, you should delete any unused go, unless you're using some sort of pool. \$\endgroup\$ – Louis Garczynski Jan 25 at 2:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.