How to Display Soil Dust in Unity
Soil Dust events, dynamically simulated in Vortex Studio, can be used to render dust particles in Unity during simulation. When the Soil Dust instance is loaded, a Soil Dust prefab is loaded from an asset bundle file located in the same directory as the Vortex file that contains the Soil Dust.
Manually creating prefabs and Asset Bundles
To manually create assets for the Soil Dust, a Unity project with the Vortex Integration Package is needed (such as VortexUnityTools or your own project), some Soil Dust prefabs must be added and the assets must be packaged in asset bundles.
For an overview of the assets workflow, refer to Workflow for Preparing and Using Assets for a Vortex Simulation with Unity Graphics.
Soil Dust Prefabs
At simulation time, when a Soil Dust instance is added, the Vortex Integration will look for a Soil Dust prefab with a specific name. The prefab name must contain the Graphics' Soil Dust hierarchy with the Graphics' Soil Dust name from the Vortex Editor explorer without the parent element that is contained in a Vortex file. The hierarchy levels are separated with period characters. Folders are omitted from the hierarchy. The name and hierarchy are case sensitive.
For example, for the following hierarchy, the prefab name would be Soil Dust.Graphics.
Creating a Soil Dust Prefab
The Soil Dust prefab must have a Vortex Soil Dust component.
- Create an empty GameObject
- Rename it with the proper name (see the Soil Dust Prefabs section introduction)
- Select the created GameObject and add the VortexSoilDust components in the inspector
- Duplicate the Packages/Vortex Studio Unity Integration/Runtime/Resources/Effects/defaultSoilDustEffect visual effect graph asset in your project by drag and dropping the file in another folder
- Rename the copied defaultSoilDustEffect file, ex: SoilDustEffect
- Assign the copied visual effect file to the Effect Asset field in the Vortex Soil Dust component properties
- Assign a texture to the Particles Texture field
- Drag and drop the GameObject somewhere in the asset bundle folder in the project pane to create the prefab
In the following section, we present in greater detail the required components for a Soil Dust prefab.
The VortexSoilDust Component
The VortexSoilDust component is in charge of managing the Soil Dust events and to spawn dust particles.
These public fields can be configured through the inspector:
Field | Description |
---|---|
Particles Texture | The texture applied to the particles |
Emission Rate | Particles emission multiplier |
Particles Lifetime | The particles life span |
Spray Cone Angle | Determines the maximum offset angles a particle can take when it is spawn with a certain initial direction |
Spray Linear Speed Range | Determines the range of linear speeds the particles can travel |
Gravity Force | Force applied to the particles |
Drag Coefficient | Drag forces apply to the particle so it resists all other forces (air resistance) |
Color Over Life | Particles color and transparency over lifetime |
Size Range | The size range for the particles |
The defaultSoilDustEffect Visual Effect
The particles are simulated and drawn with a Visual Effect Graph asset. For distributed simulation, it is important to make sure that the spawned dust particles will have the same state on all renderers. Random number generators should be avoided when modifying the defaultSoilDustEffect Visual Effect to make sure the effect will be consistent on the different screens.
Creating an Asset Bundle
Once the Soil Dust prefabs are created, they can be packaged in asset bundles so that they can be loaded by VortexUnityApp, or your own similar Unity application with Vortex Integration.
The process for generating an asset bundle is described in this section. In short, you can use the Export Asset Bundle... command from the context menu when selecting the folder containing the prefab's assets.
Then, select the file's destination and name to create the file.
In order to get VortexUnityApp to load the asset bundles properly, the asset bundles files should be placed in the same folders where are stored the Vortex file that contains the Soil Dust.