Foliage Swapper


The initial idea arose from wanting leaves falling from individual trees, which would mean the use of foliage actors. However, having an entire forest of foliage actors would not be feasible.

And so this project was born, to swap between cheap instanced static meshes for more expensive actors within a set radius of the player.
This way I could fully utilize Unreal's instanced static mesh system to reduce the amount of draw calls, but with the added benefit of having normal actors close to the player where it matters.


• Reduced amount of drawcalls compared to foliage actors.
• All-in-one Blueprint Component with easy customizability.
• Flexible use, add particles, physics-based foliage and much more.

Getting & Saving Instance Data

Getting the data from each individual instance was trickier than I initially thought. To extract all the data I needed from "InstancedFoliageActor" I had to use collision hits. Therefore I had to use a sphere collider attached to the player. However, as Unreal only calculate collisions with the root component I had to make the blueprint its own actor, instanced by a seperate component on the player and set to the players location. Nevertheless I got the individual instance data, like foliage index and transform data. I save all this data as a blueprint Struct.

Spawn Actor & Delete Instance

With the static mesh instance data saved I could proceed by spawning the associated Actor from a user controlled map, aka a dictionary.
The map allow the user to define what the instance should be replaced with. Adding the saved struct to a list of swapped foliage.
And finally deleting the static mesh instance using the instance index.

Read Saved Data & Swap Back

For each item in the swapped foliage list I then check if the distance to the actor is greater than than the value set by the user.
If it falls outside the distance I destroy the foliage actor, instantiate the correct static mesh using its saved transform to the "InstancedFoliageActor". Finally I remove the saved stuct from the list.


Although I achieved what I set out to do in the end, I had to overcome some difficulties with how Unreal handles collision.
Namely how it only calculates collision hits with the root component.
If I had more time I would've liked to investigate if I could make it more compact using traces.

Thank you for reading!


Rural Australia by Andrew Svanberg Hamilton