Configure a pre-defined Scene Initializer
The Permutations package contains a number of pre-configured Scene Initializers. Each Initializer is executed exactly once on scene Start
(after entering Play mode, and before any Update
methods are called for the first time), applying parameterizable, semi-random modifications to the scene's default configuration.
At a high level, you will need to do the following for any of the pre-defined Initializers:
- Add the Scene Initializer component to a GameObject in your scene
- Select the preset Initializer to use
- Configure your asset selection:
- If modifying an area or objects in an area of your scene, configure your Region
- If using assets not yet in your Scene—that is, from disk—configure your Asset Group
- Set the parameters for the selected Initializer
Continue reading for an in-depth explanation of each of the preconfigured Scene Initializers.
What's that colored box?
If you've selected an Initializer that affects an area in your environment, you'll notice that a box outline has been added to your scene. This is the Region that your Initializer will operate on—in this case, where you'll spawn the assets. If needed, you can change the shape of the Region—check out the Configure the asset selection guide for more.
Spawn Assets in Region
Spawns and randomly distributes assets from disk within a Region, using Poisson disk sampling to determine spacing and distribution.
Asset selection — This Initializer requires you to configure the shape and location of the Region in order to define where to place the assets, as well as an Asset Group to select which assets from disk to spawn.
If you're using the sample warehouse assets that come with this package, a set of example Asset Groups are provided under
Assets/Samples/Simulation Permutations/<version>/Warehouse/AssetGroups
. Note that, for spawning, thePlaceablePallet Variant
s should be used in your Asset Groups, as their transform roots have been configured to sit on top of a floor plane.
Parameters
Minimum Sampling Radius — The minimum allowable distance between the centers of two objects. This value should be at least as large as the half the longest side of the objects being placed to guarantee nothing collides.
Offset From Floor — The distance above the "ground plane" of the Region that objects will be spawned. A value of zero could potentially cause objects to intersect with the floor when spawned. Larger values will allow objects to fall and "settle" when the simulation starts.
Maybe Spawn Assets in Region
Similar to Spawn Assets in Region, but rather than filling the Region with an even distribution of objects, a randomly selected number of objects will be spawned and placed within the Region. Since this Initializer also utilized Poisson disk sampling to determine placement, if larger number of assets are selected than there are available spaces in the scene for them to be placed, the algorithm will exit early without spawn any of the extraneous assets.
Asset selection — This Initializer requires the configuration of the shape and location of the Region in order to define where to place the assets, as well as an Asset Group to select which assets from disk to spawn.
Parameters
This Initializer will have the parameters from Spawn Assets in Region alongside additional parameters:
Minimum Sampling Radius — The minimum allowable distance between the centers of two objects. This value should be at least as large as the half the longest side of the objects being placed to guarantee nothing collides. Offset From Floor — The distance above the "ground plane" of the Region that objects will be spawned. A value of zero could potentially cause objects to intersect with the floor when spawned. Larger values will allow objects to fall and "settle" when the simulation starts. Min Random — The minimum possible number of objects to add, inclusive. Max Random — The maximum possible number of objects to add, inclusive.
Prune Random in Regions
Selects a random set of objects which meet the filter criteria and removes them from the scene.
Asset selection — This Initializer requires the configuration of the shape and location of the Region to define where to select assets from to prune.
Parameters
Min Random — The minimum possible number of objects to remove, inclusive. Max Random — The maximum possible number of objects to remove, inclusive. Names Contain — A substring which must exist in the name of an object in the Region for it to qualify for removal. If the Region is very tightly constrained such that only candidates for pruning are encapsulated, you can simply leave this field blank.
Perturb Objects in Region
Applies a small, random perturbation to each object's orientation and position in the scene.
Asset selection — This Initializer requires the configuration of the shape and location of the Region to define where to select assets from to perturb.
Parameters
Maximum Displacement — Maximum possible translational displacement that can be applied to an object, exclusive. Maximum Euler Rotations — Maximum values for rotation in degrees along X, Y, and Z axes (pitch, yaw, and roll, respectively) that can be applied to an object.
Glossary
Asset: any item that you use in your Unity project, such as a 3D model
Colliding: describes any object whose Colliders are intersecting with another object's colliders in the scene
Initializer: a script which executes a pre-defined list of Operations on a Region in the scene
Prune: similar to Destroy; remove an Environments-managed instance of an object from the scene
Region: a collection of boundaries in the scene which define the space within which an Initializer can act
Spawn: similar to Instantiate; create a brand new, Environments-managed instance of a given object in the scene