#Baked entity prefab cross-referencing

1 messages · Page 1 of 1 (latest)

pseudo valve
#

Imagine a building construction system. You create a prefab for a "foundation" object and bake it. Now you also want a way to turn these foundations into actual buildings, by replacing it with a different prefab which represents the next progression. A tree structure would work for this:

Foundation > Platform
Foundation > House > Castle
Foundation > House > Stable
Foundation > House > Blacksmith

etc...

The best workflow I can imagine would be to simply have a GameObject[] upgradeTo; field in every authored prefab, then drag and drop whichever prefabs it can transition to. Ideally, upon baking, the GameObject prefab references will be converted to the corresponding baked entity prefab.

But how would you accomplish this in practice? How would the baker know which entity was made from those other prefabs in the list, especially when they might not even be baked yet? Baking them manually would result in a mess of duplicated entities. If I start by only baking the root, then bake down the tree recursively, the game could freeze or crash if there is ever a loop. I just don't know how I could make this workflow work.

I'm currently trying to use EntityPrefabReference, although I think I'm going to abandon that path as I can't get it to work. But would that be on the right track?

pseudo valve
#

Good god, I should have just done it, instead of inventing reasons it might not work. It totally works by just using GetEntity(upgradeTo[i], ...). No duplicates or anything. I'm having difficulty wrapping my head around how baking works behind the scenes.