-
Notifications
You must be signed in to change notification settings - Fork 0
Step 4: Loot System Guide
URF provides a flexible loot and XP reward system with:
- Direct XP rewards
- XP pickup rewards
- Hybrid rewards
- Guaranteed pickup drops
- Random loot tables
- Pickup pooling support
For production enemies, use URFEnemyLogicComponent together with URFHealthComponent.
AURFTestEnemy is still supported for quick prototyping and backward compatibility, but production enemies should use their own ACharacter or APawn with URF components.
Create your own enemy Blueprint from ACharacter or APawn.
Recommended setup:
BP_ProductionEnemy +-- CapsuleComponent or custom collision +-- SkeletalMesh or StaticMesh +-- URFHealthComponent +-- URFEnemyLogicComponent
For enemies spawned outside URFGameDirector, enable URFEnemyLogicComponent -> Auto Register With Director if you want the director to track alive enemy count and unregister them on death.
Optional:
+-- URFSeparationComponent
In URFHealthComponent:
Max Health -> 50
Destroy On Death -> true
Destroy Delay -> 0.1
Recommended production setup:
URFHealthComponent -> Destroy On Death -> true
URFEnemyLogicComponent -> Handle Actor Destruction -> false
This keeps actor destruction in the health component, while URFEnemyLogicComponent handles XP, loot, and Game Director unregistering.
URFEnemyLogicComponent listens to the owner's URFHealthComponent death event. When the enemy dies, it processes rewards once, unregisters from the director, and then leaves destruction to the selected destruction owner.
In URFEnemyLogicComponent:
XP Reward -> 10
Reward Method -> Direct On Kill
Guaranteed Pickup Class -> None
Enable Random Loot -> false
Reward Method controls how XP is awarded.
Available modes:
-
Direct On Kill- XP is added directly to the killer'sURFExperienceComponent -
Pickup Only- XP is spawned as a pickup -
Hybrid- Part of the XP is awarded directly, the rest is spawned as a pickup
Use this for enemies that immediately give XP when killed.
XP Reward -> 10
Reward Method -> Direct On Kill
Guaranteed Pickup Class -> None
Enable Random Loot -> false
Result:
Player receives 10 XP immediately.
No XP pickup is spawned.
Use this for enemies that drop XP pickups.
XP Reward -> 20
Reward Method -> Pickup Only
Guaranteed Pickup Class -> BP_XPPickup
Enable Random Loot -> false
Result:
Enemy drops one XP pickup worth 20 XP.
Player must collect it.
Use this for enemies that give some XP directly and drop the rest.
XP Reward -> 100
Reward Method -> Hybrid
Hybrid Direct XP Percentage -> 0.3
Guaranteed Pickup Class -> BP_XPPickup
Enable Random Loot -> false
Result:
Player receives 30 XP directly.
Enemy drops one XP pickup worth 70 XP.
Use this for enemies that give XP and also roll bonus loot.
XP Reward -> 10
Reward Method -> Direct On Kill
Enable Random Loot -> true
Random Loot Tables
+-- DA_CommonEnemyLoot
Result:
Player receives 10 XP directly.
Enemy also rolls DA_CommonEnemyLoot.
Example boss setup:
XP Reward -> 500
Reward Method -> Pickup Only
Guaranteed Pickup Class -> BP_XPPickup_Large
Enable Random Loot -> true
Random Loot Tables
+-- DA_BossLoot
+-- DA_RareLoot
+-- DA_PowerupLoot
Result:
Boss drops one large XP pickup.
Boss rolls multiple loot tables.
URFLootDropDataAsset defines random loot drops.
Each loot entry contains:
-
PickupClass- What pickup actor to spawn -
DropChance- Chance to drop, from 0.0 to 1.0 -
MinXPAmount- Minimum value passed to the pickup -
MaxXPAmount- Maximum value passed to the pickup -
Use Random XP Amount- If true, randomizes between min and max
- Right-click in Content Browser
- Create a loot drop data asset
- Name it, for example
DA_CommonEnemyLoot - Add loot entries
- Assign it to
URFEnemyLogicComponent -> Random Loot Tables
Only one item can drop per roll, or nothing drops.
Example:
Gold Coin -> 0.6
Health Potion -> 0.3
Result:
60% chance for Gold Coin
30% chance for Health Potion
10% chance for nothing
Each entry rolls independently.
Example:
Gold Coin -> 0.6
Health Potion -> 0.3
Rare Chest -> 0.05
Result:
Gold can drop independently.
Health can drop independently.
Rare Chest can drop independently.
Multiple items can drop at once.
Name -> DA_CommonEnemyLoot
Allow Multiple Drops -> false
Entries:
Gold Coin
Drop Chance -> 0.6
Pickup Class -> BP_GoldPickup
Min Value -> 5
Max Value -> 10
Health Potion
Drop Chance -> 0.3
Pickup Class -> BP_HealthPickup
Min Value -> 15
Max Value -> 25
Result:
60% gold
30% health
10% nothing
Name -> DA_BossLoot
Allow Multiple Drops -> true
Entries:
Large Gold
Drop Chance -> 1.0
Pickup Class -> BP_GoldPickup_Large
Rare Item
Drop Chance -> 1.0
Pickup Class -> BP_RareItem
Bonus Chest
Drop Chance -> 0.5
Pickup Class -> BP_Chest
Result:
Large Gold always drops.
Rare Item always drops.
Bonus Chest has a 50% chance to drop.
URFEnemyLogicComponent exposes:
OnRewardsProcessed(AActor* Killer, int32 XPAwarded, bool bPickupSpawned)
Use this event for:
- Death effects
- Reward sounds
- Floating text
- Analytics
- Custom Blueprint reactions after rewards are processed
Example:
OnRewardsProcessed
-> Spawn reward VFX
-> Play reward sound
You can manually process rewards with:
HandleXPReward(AActor* Killer)
This processes XP and loot rewards only.
It does not:
- Destroy the actor
- Mark the enemy as dying
- Unregister from Game Director
This is useful for custom death flows where you want full Blueprint control.
Use Direct On Kill for fast arcade-style XP.
Reward Method -> Direct On Kill
Use Pickup Only when you want XP to appear in the world.
Reward Method -> Pickup Only
Guaranteed Pickup Class -> BP_XPPickup
Use Hybrid for bosses or special enemies.
Reward Method -> Hybrid
Hybrid Direct XP Percentage -> 0.3
Guaranteed Pickup Class -> BP_XPPickup
Use random loot tables for gold, health pickups, chests, powerups, and rare drops.
Enable Random Loot -> true
Random Loot Tables -> DA_CommonEnemyLoot
Separate loot categories into different tables:
DA_CommonLoot
DA_RareLoot
DA_BossLoot
DA_PowerupLoot
This makes balancing easier.
Contact damage uses overlap events.
Check:
-
URFEnemyLogicComponent -> Enable Contact Damageis true -
Contact Damage Component Namematches the exact primitive component name - The contact damage component has
Generate Overlap Eventsenabled - The contact damage component uses
Pawn -> Overlap - The player collision also allows overlap with the enemy contact component
If the enemy blocks the player capsule instead of overlapping it, contact damage will not fire.
Check destruction settings.
Recommended:
URFHealthComponent -> Destroy On Death -> true
URFEnemyLogicComponent -> Handle Actor Destruction -> false
Alternative:
URFEnemyLogicComponent -> Handle Actor Destruction -> true
Use one destruction owner, not both.
Check:
- Enemy has
URFEnemyLogicComponent - Enemy has
URFHealthComponent - Player has
URFExperienceComponent -
XP Rewardis greater than 0 -
Reward Methodis configured correctly - The enemy actually reaches zero health
- For
Direct On KillorHybrid, the killer/player actor hasURFExperienceComponent
Check:
-
Reward MethodisPickup OnlyorHybrid -
Guaranteed Pickup Classis set - Pickup class is valid
- Enemy has a valid world location
- Pickup collision is not blocking spawn
Check:
-
Enable Random Lootis true -
Random Loot Tablescontains at least one valid loot table - Loot table has valid entries
- Entry
PickupClassis valid - Drop chances are high enough for testing
For testing, temporarily set:
Drop Chance -> 1.0
Check:
- Rewards were not already processed
- Enemy has
URFEnemyLogicComponent - Enemy death is routed through
URFHealthComponent -
HandleXPRewardor health death event is actually called
For production enemies:
Enemy Blueprint
+-- URFHealthComponent
+-- URFEnemyLogicComponent
Use URFEnemyLogicComponent for:
- XP reward setup
- XP pickup spawning
- Random loot tables
- Game Director registration
- Reward events
Use URFHealthComponent for:
- Health
- Death detection
- Optional actor destruction
- Optional contact damage