We can use the earlier mentioned landscape generation code to create a landscape, and the procedural foliage functionality to randomly distribute some foliage on it.
Combining the capabilities of the Landscape API and Foliage API will allow you to procedurally generate complete maps. In this recipe, we will outline how this is done.
We will programmatically create a landscape and populate it with foliage using code.
To prepare to perform this recipe, we will need a UE4 project with a Generate
button to kick off generation. You can see the Landscape API – Landscape generation with Perlin noise recipe for an example of how to do this. You simply need to create a small UMG UI widget that has a Generate
button. Connect the OnClick
event of your Generate
button to a C++ UFUNCTION()
inside any C++ global object, such as your Chapter12GameMode
object, that will be used to generate your terrain.