Randomly Generated Foliage


The Foliage Blueprint shows how to use a Blueprint to create randomly-generated foliage (or potentially other structures) that are automatically placed such that they conform to a surface. The user has control over the extent of the effect and how many meshes the system will try to spawn. As the Blueprint is moved, the meshes update to re-conform to the new environment.

At a glance, the system takes a set radius then selects randomly-generated points within that radius to use as potential spawn points. It then performs a downward trace check to see where the surfaces are beneath each point, and uses those as potential locations. The system also checks the individual radius of each mesh to keep meshes from overlapping too heavily, and will choose new random locations whenever there is no room for a mesh at its current one.

Blueprint Setup

The Components List, Construction Script, and Event Graph for this Blueprint perform the following tasks:

Blueprint Aspect


Components List

Adds a BillboardComponent to represent the center and a BoxComponent to help visualize the construction radius.

Construction Script

The Construction Script performs the following tasks:

  • Scale the Box Component to help with visualization.

  • Use a loop to create a foliage mesh at a random location within the radius, for the desired number of meshes.

  • Check against a variety of situations to see if and how a mesh should be spawned.

Event Graph

This Blueprint has no Event Graph, meaning that once its properties are set, it remains the same throughout gameplay.

Editable Variables

As you might expect, most of the work of this Blueprint is done in the Construction Script, which is quite extensive. Below are the key exposed properties as well as their purposes.

MyBlueprintNoVar.jpg Properties_Foliage.png



Number of Meshes

This integer value is the number of meshes the Blueprint will attempt to spawn. In the Construction Script, this value determines the number of times a ForLoop node will trigger. Each execution coming out of the ForLoop node passes through the section of script responsible for creating the Static Meshes.


Controls the radius of the effect, within which the foliage will be randomly scattered.

Collision Trace Range

This is the vertical distance (how far down the system will look) to find a valid surface on which to spawn foliage.

Meshes To Spawn

This is an array variable, which meshes from the Content Browser can be added to. After the Construction Script spawns a mesh component, it is changed to a mesh picked at random from this array.

Vertical Offset

Controls how far into a surface a mesh will be spawned. This can help meshes appear more grounded.

Align To Surface

This Boolean variable causes meshes spawned by the Blueprint will orient themselves such that they match the angle of the surface upon which they are resting. Internally, this variable affects a branch in the Construction Script that determines the method used for positioning the foliage meshes. When enabled, the script draws a line trace before attempting to spawn each mesh. When the trace hits a surface, the angle and height of the impact point is retrieved and used to determine the angle and height of the mesh being spawned.

Scale Max

Maximum scale allowed for the spawned meshes. This is a 0.0-1.0 percentage value, with 1.0 representing 100%.

Scale Min

Minimum scale allowed for the spawned meshes. This is a 0.0-1.0 percentage value, with 1.0 representing 100%.

Cluster Around Center

This Boolean variable determines whether or not the randomized locations for the meshes will be primarily located around the center of the radius. When this option is enabled, the distance meshes can spawn from the center point is reduced by a random amount, causing fewer meshes to spawn the farther away the system looks from the radius.

Scale Falloff

This Boolean variable determines whether or not spawned meshes will be smaller when they sit further away from the center point. The Boolean decides whether the scale of the meshes will be multiplied by a value derived from the mesh's distance from the center. When using the Blueprint to generate foliage meshes, the cluster of meshes takes on a more natural look when grass and flowers taper off in size around the outer edges of the group.

Random Seed

Controls the seed applied to create a random number. Change this to vary your results.