Procedurally place actors over a landscape
One of the functions proposed by the Landscape Generator is the procedural placement of actors over the landscape. Using the procedural actor spawning allow us to place complex objects over the landscapes, like particle emitters, sound emitters, or complex meshes.
As the actors are not managed like the foliages, the process of generating and spawning actors is managed differently. Let’s quickly see the principles of the procedural actor spawning.
Generate a water plane.
A water plane is a particuliar actor. It has its own generation function which is really simple to use.
The parameters of this function are:
Target: the landscape where the water plane will be generated.
Water Material: the water material to apply on the water plane.
Elevation: the height of the water plane.
Delete Foliage Below Water Level: if true, then all foliages under the water plane will be removed.
Tile Index X: the X index of the landscape (when using tiled landscapes)
Tile Index Y: the Y index of the landscape (when using tiled landscapes)
Generate any kind of actors.
The generation of actors is splitted in two steps (like the foliages): generation and spawning. Let’s focus first on generation.
Generate Actors
The function generate actors is Generate Actors. Its purpose is to place objects over a landscape, like the Generate Objects of foliages. However, it doesn’t spawn them.
As we can see, there are lot of parameters. First let’s focus on the Generate Actors parameters:
Meta Landscape: the landscape where we want to generate objects.
Module: the probability mask (works the same way the module of Generate Objects and Generate Forests).
Template: the template of the actor to generate, we will discuss this later.
Discretization Step: the discretization step; actors will be generated at the junctions of a virtual grid, this parameter represents the width of a grid cell. In simpler words, the lower the value, the higher the density of actors.
Randomization Radius: as we just said, the actors are generated using a grid, this parameter introduce some randomness by allowing us to specify how far from the junctions of the grid, the actors can be generated. In simpler words, a higher value will make the actors placement less regular.
Random Yaw: a boolean to specify if we want to randomize the rotation around the Z-axis.
Min ZOffset:
Max ZOffset:
Note that once the actors are generated, they are not spawned yet. So it’s totally possible to manually edit these elements before spawning them. For instance, the Class parameter is used to specify the class of the actors generated by the Generate Actors function.
Details about ActorElement
One of the key point of the Generate Actors function is the parameter template. It describes the parameter of the actors which are going to be generated. These parameters are the standard parameters for spawning actors, thus we can find the detailed documentation of each one of these parameters in the Unreal Engine documentation.
An important thing to note is that the Generate Actors function will take the Actor Element as a template to generate (and return) a lot of new Actor Element. These new elements will share the same parameters as their template, except for the location and the rotation.
As we can see, calling Get Elements on the result of this node will return an array of Actor Element. Before being spawned, these elements can be edited manually to change their location, or eventually other parameters like their class or their owner, allowing us to have a fine control on the actors we want to spawn.
Spawn Actors
Now that the positions of the actors are generated over the landscape, we can proceed to spawn the actors. This function takes as parameter the actor elements, and returns the spawned actors.