- Harvestable foliage that respawns over time
- Performance-friendly handling of thousands of foliage elements
- Consistent behavior between resource nodes and foliage-based harvestables
- The Foliage System handles what is harvested (instances vs actors, visuals, interaction)
- The Respawn Manager handles when a harvested element comes back
- Instance-based foliage
- Actor-converted foliage
- Integration with LootComponent and Inventory
1. Two Ways to Treat Foliage
1.1 Direct Instance Management (Pure Foliage)
- You harvest foliage by removing / hiding instances from an Instanced Static Mesh (ISM/HISM).
-
Respawn Manager stores “respawn tasks” tied to:
- A component reference
- Instance index
- World position
- Respawn Manager calls back into your Foliage System
- The system re-adds an instance at the same (or slightly randomized) position
1.2 Foliage → Actor Conversion (Hybrid)
-
On first interaction, you convert a foliage instance to a “real” actor (e.g.,
BP_HarvestablePlant). -
That actor:
- Handles interaction
- Has optional LootComponent
- Registers itself with Respawn Manager when harvested
-
The actor either:
- Re-enables itself, or
- Notifies the Foliage System to recreate an instance and optionally destroys itself
2. Simple Pattern — Actor-Based Foliage Nodes
This is closest to the resource-node pattern you already have.Setup
For each harvestable plant/bush/grass patch:-
Blueprint:
BP_FoliageNode -
Components:
StaticMesh(or SkeletalMesh)LootComponent(optional)
-
Variables:
RespawnTimebHasBeenHarvested
BPI_Respawnable (Blueprint interface) or IRespawnable in C++.
On Harvest (Blueprint)
On Respawn (Blueprint)
3. Instance-Based Pattern — Respawning HISM Instances
If you keep foliage as true instances, you’ll be working at the component/instance index level.Concept
-
On harvest:
-
FoliageInteractionManager knows:
- The
UHierarchicalInstancedStaticMeshComponent* - The
InstanceIndex - The
WorldLocationof that instance
- The
- You remove or hide the instance
- You register a respawn task with Respawn Manager
-
FoliageInteractionManager knows:
-
On respawn:
- Respawn Manager calls back into FoliageInteractionManager
- Manager re-adds the instance (possibly with some rule: same spot, random nearby, etc.)
3.1 Data Needed per Respawn
You need enough info to recreate an instance:- A reference to the HISM/ISM component (or an ID that can find it)
- The desired transform (location/rotation/scale)
- (Optionally) a foliage type or tag
3.2 On Harvest (C++ Pseudocode)
InFoliageInteractionManager or similar:
3.3 On Respawn (Manager → Foliage System)
Respawn Manager at some point calls:4. Hybrid Pattern — Foliage Instance → Temporary Actor → Respawn
If you want richer behavior (durability, health, multi-hit harvest, etc.):- Player interacts with foliage instance
-
FoliageInteractionManager:
- Hides/removes the instance
- Spawns a temporary actor (e.g.,
BP_ShrubActor) at that location
-
The temporary actor:
- Has
LootComponent(optional) - Handles hits/harvest logic
- Registers with Respawn Manager when fully harvested
- Has
-
On respawn:
-
Either:
- The actor reparents back to an instance and then destroys itself, or
- The actor simply re-enables itself (if you don’t care about reverting to pure foliage)
-
Either:
- Cheap instance-based rendering initially
- Rich interaction once the player gets close
- Centralized respawn behavior
5. Integrating Loot and Inventory
For foliage that drops items:-
Use
LootComponenton the actor version (tree, bush, etc.) -
On harvest:
LootComponent → GenerateLoot- Add items to player inventory or spawn
WorldItemActors
- Respawn Manager handles the timing
-
LootComponent → ResetLooton respawn
- Let FoliageInteractionManager call into a central loot function using
LootTable - Spawn
WorldItemActors at the harvest location - Still use Respawn Manager purely for regrowing the instance
6. Multiplayer Considerations
Same rules as elsewhere:-
Only the server should:
- Remove foliage instances
- Register respawn requests
- Re-add instances or respawn actors
-
Clients only see:
- Replicated actors (for actor-converted foliage)
- The final mesh appearance (for instances, via normal replication or deterministic regeneration)
7. Performance & Scaling Tips
-
Do not create a dedicated actor for every foliage instance in a large forest.
Use instance-based or hybrid patterns instead. -
If you have massive foliage counts:
- Group respawns by area (region tags, grid cells, etc.)
- Optionally spread respawns over time (e.g., max X respawns per frame).
- Use simple collision and minimal tick on temporary actors; they likely don’t need Tick at all.
8. Recommended Use in Your Framework
Given your goals:- Use Respawn Manager as the one and only scheduling layer.
-
Let FoliageInteractionManager focus on:
- Detecting interactable foliage
- Converting instances to actors (when needed)
- Feeding loot and respawn requests into the manager
-
Keep LootComponent logic consistent between:
- Trees / rocks / ore nodes
- Foliage-based nodes
9. Summary
- Respawn Manager is not foliage-specific; it’s a generic respawn pipeline.
-
Foliage systems integrate by:
- Either using actor-based nodes
- Or managing HISM/ISM instances with respawn entries
-
You decide how fancy you want the foliage interaction to be:
- Simple instance re-addition
- Hybrid conversion to full actors
- Full loot + durability behavior