Skip to main content
Reference

Foliage Actor

The FoliagePluginActor is the Actor that replaces a foliage instance. Create a Blueprint subclass of it and set it as Foliage Actor Class in the Data Table.

Its events and functions are listed under Override in the My Blueprint panel:

Overridable events and functions

Components​

ComponentDescription
RootScene root.
Foliage MeshStatic mesh component. The plugin sets it to the instance's mesh.

Add a Geometry Collection Component yourself if you use destructible meshes.

Events​

EventRuns onCalled when
BPE On Foliage DamagedServerThe actor was harvested. Receives the damage, instigator, causer, damage type and rewards.
BPE On Foliage Remaining Uses UpdatedServer and clientsThe remaining uses changed.
BPE On Foliage Mesh UpdatedServer and clientsThe mesh was set, right after the actor was spawned.
BPE On Foliage DepletedServer and clientsThe remaining uses reached 0. Called once.
BPE On Foliage InteractedServerThe actor was harvested with Interact instead of damage. Receives the instigator, causer and rewards. See Interaction and Pickups.
BPE On Foliage Returned To PoolServer and clientsThe actor was returned to the pool. Only used with actor pooling.

The same events are also available as the bindable delegates On Foliage Remaining Uses Updated, On Foliage Mesh Updated and On Foliage Depleted, for example to listen from a widget.

Overridable functions​

FunctionDefault behaviorOverride to
Handle Foliage DamageChecks the damage type, gives the reward, reduces the remaining uses and breaks the destructible mesh.Change when a hit counts, for example with health. Call the parent to keep the default behavior.
Handle Foliage RewardCalls On Foliage Harvested on the first of the Instigator, the Instigator's Pawn and the Damage Causer that implements the interface. Returns false if none of them does. Also called by Interact.Give rewards in your own way. If you override it, call On Foliage Harvested yourself if you still want the interface to be used.
Handle Destructible DamageBreaks the destructible mesh at the hit location. Runs on server and clients.Break the mesh in your own way.
Handle Foliage Impulse on DepletionPushes the mesh near its top in a random direction, scaled by its mass and Physics Impulse Multiplier.Make it fall in a specific direction, for example away from the player.

Handle Foliage Damage and Handle Foliage Reward only run on the server.

Functions​

FunctionDescription
Foliage Get DataReturns the actor's row from the Data Table.
Foliage Get Remaining UsesReturns the remaining uses.
Foliage Get RewardReturns Rewards on Harvest from the row.
Get Geometry Collection ActorReturns the actor that shows the destructible mesh, or none if the mesh has no destructible version.
Is In PoolTrue while the actor is unused in the pool.
InteractHarvests the actor once without damage: gives the rewards, reduces the remaining uses by 1 and calls BPE On Foliage Interacted. Returns false if Allow Interaction is off or no uses are left. Server only.
Reduce Remaining UsesReduces the remaining uses. Server only.
Add Remaining UsesAdds remaining uses. Server only.
Set Remaining UsesSets the remaining uses. Server only.

Reduce, Add and Set Remaining Uses can be called from inside your Foliage Actor Blueprint.

Actor pooling​

With Enable Actor Pooling on in the Plugin Settings, a Foliage Actor that is done is not destroyed. It is hidden, its collision is turned off and it is kept for the next instance of the same Foliage Actor class. This saves spawning and destroying actors when players harvest a lot.

When the actor returns to the pool, the plugin resets what it changed itself: the remaining uses, physics, collision, materials, the mesh transform, and the destructible mesh. Then it calls BPE On Foliage Returned To Pool on the server and every client.

warning

Begin Play only runs the first time the actor is spawned. If your Blueprint changes something on the actor, for example spawns effects, attaches components or sets variables, reset it in BPE On Foliage Returned To Pool. Use BPE On Foliage Mesh Updated for setup that should run each time the actor is used.

In this example the Foliage Actor counts its hits in an integer variable Hit Count. Without the reset, a reused actor would start counting from the previous tree's value:

Reset a variable in BPE On Foliage Returned To Pool

At most Max Pooled Actors Per Class unused actors are kept per class. Actors beyond that are destroyed as usual.