Nested Prefab Randomization¶
When a prefab actor is randomized, it would randomize the seed of every nested child prefab down to the lowest level
This allows you to have interesting randomization with more complex nested prefabs built from simpler prefab collections
In this example, we’ll assemble the following building:
Sample Nested Prefab Preparation¶
We will build the building prefab using the following smaller prefabs * Ground Floor Prefab - Represents the ground floor / entrance of the building * Floor Prefab - Represents a single floor * Roof Prefab - Roof of the building * Facade Decoration - The decoration added to the facade of the building (fire exit)
Since we have multiple variations for each of these prefabs, we’ll use prefab collections for the above 4
Ground Floor Prefab Collection¶
We have assembled 2 ground floor prefab variations. Add them into a GroundFloor prefab collection
Floor Prefab Collection¶
We have assembled 3 floor prefab variations. Add them into a Floor prefab collection
Roof Prefab Collection¶
We have assembled 2 roof prefab variations. Add them into a Roof prefab collection
Facade Decoration Collection¶
We want to decroate the facade of the buildings and prepared 5 different prefabs for it
An empty prefab was included in the list so we don’t have any decorations sometimes
Note
Make sure all the prefabs in your collections have consistent pivots so all the items in the collection spawn consistently in the right place
Sample Nested Prefab Assembly¶
Now that we have the pieces in place, assemble our master building prefab
Drop in the ground floor prefab collection on to the scene
Drop as many floor prefab collections as necessary
Drop in the roof prefab collection
Drop in the facade decoration prefab collection
Select the prefabs you just dropped by holding the Control key and clicking on them
Create a prefab with the current selection
Sample Nested Prefab Randomization¶
Select your newly created prefab and click Randomize. It would randomize everything inside it (the floors, ground floor, roofs, facade decorations)
Nested Child Prefab Randomization¶
You can select child prefabs and randomize them individually for more fine tuned control