unreal engine
Foliage Plugin + Survival Game Kit (SGT)
Create the Data Table (Foliage Data)
Create a Blueprint Class of type FoliagePluginActor
Assign the Data Table and the Foliage Actor in the Project Settings
(FOLIAGE ACTOR HAS BEEN MOVED TO THE DATATABLE)
Change the Component Class for your Foliage to use the “FoliagePluginComponent“
Create a new Tree resource in the Foliage Data Table you previously created, see example below
Set the BP_FoliageActor class that you created earlier in the DataTable
Create a new Rock resource in the Foliage Data Table you previously created, see example below
In the BP_SurvivalCharacter Blueprint, add the Foliage Plugin Interface
Example of adding the harvested resources to our inventory
Example of how to enable Melee Weapons to harvest Trees and Rocks
OPEN THE “BP_MASTERMELEEWEAPON” BLUEPRINT (/BLUEPRINTS/HOLDABLES/BP_MASTERMELEEWEAPON) AND MODIFY THE “GIVE DAMAGE ONCE” FUNCTION TO THE EXAMPLE BELOW
Example of how to enable harvesting with “E” Interact Key
Open the “BP_PlayerInventoryComponent” (/Blueprints/Components) and modify the “Is inventory actor?” macro
Open the “Is interactable?” Macro and modify as such
Foliage Plugin Damage Types
Setting up Damage Types for the Foliage Plugin
If you haven’t setup the Foliage Plugin yet, follow this tutorial first.
Create a new Blueprint Class based on the DamageType
Set the new Damage Type required in your Foliage DataTable
When Applying damage to your Foliage, specify the new Damage Type
All done, if the incorrect damage type is applied, you will not be able to interact with the Foliage
Foliage Plugin – Destructible Meshes
Setting up Destructible Meshes with the Foliage Plugin
If you haven’t setup the Foliage Plugin yet, follow this tutorial first.
Create a Destructible Mesh of your Foliage Mesh
Example Settings of a Destructible Mesh (a rock in this example)
Add the Destructible Mesh to the Foliage DataTable you created in the previous tutorial
Important here is that the IDs (marked in RED) are the SAME, it doesn’t matter if the Destructible Mesh is Empty (if you don’t have one for a different mesh)
Another Example
Add a Destructible Component to your BP_FoliageActor that you created in the previous tutorial
All done, the Foliage Plugin will handle dealing damage and visibility of the Destructible Mesh
Foliage Plugin – Getting Started
Enable the Foliage Plugin
Create the Foliage DataTable
Create a new Foliage Blueprint Actor (FoliagePluginActor) child
In Project Settings > Foliage Plugin > Set your newly created Foliage DataTable and Foliage Actor
When Painting / Spawning Foliage, you must change the default foliage component to “FoliagePluginComponent”
Make sure your collision settings for your foliage is set to BlockAll, or your own custom collision channel
(this is only required for interacting with the foliage instances)
Add a new Entry in the Foliage DataTable, in this example we’re creating a Tree Resource
You must make sure that the Mesh you paint (or spawn) is the same in the Foliage DataTable so that the Foliage Plugin knows what to do with it.
Inside your Character (or Controller) Blueprint, Implement the Foliage Plugin Interface
Example of adding resources to your inventory when a Foliage is damaged (harvested)
Interacting with the Foliage Plugin Example
This example uses a line trace from the Players point of view to “Apply Point Damage”
Damage is handled by the Foliage Plugin and will convert your Foliage Instance to a useable / interactable foliage actor automatically.