docs: Update BP_ItemPickup setup instructions and correct C++ references
This commit is contained in:
@@ -3,15 +3,65 @@
|
||||
**Parent Class:** `Actor`
|
||||
**Category:** Inventory
|
||||
**Target UE Version:** 5.5–5.7
|
||||
**Build Phase:** 3 — Inventory
|
||||
**Build Phase:** 4 — Inventory
|
||||
**C++ Status:** 🔵 BP-Only
|
||||
|
||||
---
|
||||
|
||||
## 0. Quick Setup — How to Place an Item in the World
|
||||
|
||||
This is the most common question: "I created a `DA_ItemData` but I can't drag it into the level." Here's the correct workflow:
|
||||
|
||||
### Step A — Create the Data Asset (one-time per item type)
|
||||
|
||||
```
|
||||
Content Browser → Framework/DataAssets/Items/
|
||||
Right-click → Miscellaneous → Data Asset
|
||||
Class: DA_ItemData
|
||||
Name: DA_Item_MedKit
|
||||
Fill in: ItemTag, DisplayName, Icon, WorldMesh, Weight, StackLimit, ItemType
|
||||
If ItemType=Consumable → fill ConsumableData (HealthRestore=25, UseDuration=2.0)
|
||||
Save
|
||||
```
|
||||
|
||||
### Step B — Create the BP_ItemPickup Blueprint (one-time)
|
||||
|
||||
```
|
||||
Content Browser → Framework/Inventory/
|
||||
Right-click → Blueprint Class → Actor
|
||||
Name: BP_ItemPickup
|
||||
Implement I_Interactable interface
|
||||
Add: StaticMeshComponent (named "Mesh"), SphereComponent (named "InteractionCollision")
|
||||
Add: Config variable of type S_PickupConfig
|
||||
In Construction Script: read Config.ItemData → set Mesh to ItemData.WorldMesh
|
||||
```
|
||||
|
||||
### Step C — Place Items in Your Level (repeat per item instance)
|
||||
|
||||
```
|
||||
1. Drag BP_ItemPickup into the level
|
||||
2. Select it → Details panel → Config → Item Data → DA_Item_MedKit
|
||||
3. Set Quantity → 1 (or more for stacked items)
|
||||
4. Position it where you want it in the world
|
||||
```
|
||||
|
||||
The `BP_ItemPickup` reads the mesh, name, icon, and interaction prompt from the `DA_ItemData`. You never drag the Data Asset itself into the level — only the actor that references it.
|
||||
|
||||
```
|
||||
DA_Item_MedKit (Content Browser) ← defines WHAT
|
||||
↑ referenced by
|
||||
BP_ItemPickup (Actor in level) ← physical body in world
|
||||
↑ interacts via
|
||||
Player → BPC_InteractionDetector → I_Interactable → BPC_InventorySystem.AddItem()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. Overview
|
||||
|
||||
`BP_ItemPickup` is a world-placed or runtime-spawned `Actor` representing an item the player can pick up. It implements [`I_Interactable`](docs/blueprints/01-core/03_I_InterfaceLibrary.md) and optionally [`I_Persistable`](docs/blueprints/01-core/03_I_InterfaceLibrary.md).
|
||||
`BP_ItemPickup` is a world-placed or runtime-spawned `Actor` representing an item the player can pick up. It implements [`I_Interactable`](../01-core/03_I_InterfaceLibrary.md) and optionally [`I_Persistable`](../01-core/03_I_InterfaceLibrary.md).
|
||||
|
||||
When the player interacts (via [`BPC_InteractionDetector`](docs/blueprints/03-interaction/16_BPC_InteractionDetector.md)), the pickup calls `BPC_InventoryComponent.AddItem` with the associated item data, plays feedback, and either destroys itself or depletes a stack count.
|
||||
When the player interacts (via [`BPC_InteractionDetector`](../03-interaction/16_BPC_InteractionDetector.md)), the pickup calls `BPC_InventorySystem.AddItem` with the associated item data, plays feedback, and either destroys itself or depletes a stack count.
|
||||
|
||||
---
|
||||
|
||||
@@ -99,7 +149,7 @@ When the player interacts (via [`BPC_InteractionDetector`](docs/blueprints/03-in
|
||||
| Variable | Type | Description |
|
||||
|----------|------|-------------|
|
||||
| `WorldState` | `S_PickupWorldState` | Tracks pickup history. |
|
||||
| `OwningInventory` | `BPC_InventoryComponent*` | Cached when player overlaps interaction trigger. |
|
||||
| `OwningInventory` | `UBPC_InventorySystem*` | Cached when player overlaps interaction trigger. |
|
||||
| `RespawnTimerHandle` | `FTimerHandle` | Handle for respawn delay. |
|
||||
|
||||
---
|
||||
@@ -110,7 +160,8 @@ When the player interacts (via [`BPC_InteractionDetector`](docs/blueprints/03-in
|
||||
|
||||
| Function | Description |
|
||||
|----------|-------------|
|
||||
| `Interact_Implementation` | Implements `I_Interactable`: adds item to player inventory, plays feedback, destroys or depletes. |
|
||||
| `Public Functions` | Description |
|
||||
| `Interact_Implementation` | Implements `I_Interactable`: calls `BPC_InventorySystem.AddItem()`, plays feedback, destroys or depletes. |
|
||||
| `OnDroppedFromInventory` | Called by inventory drop system: sets transform, velocity, and respawn behaviour. |
|
||||
| `BeginPlay` | Caches references, sets up bobbing/rotation timeline, configures collision. |
|
||||
| `SetPickupEnabled` | Toggles visibility and collision. |
|
||||
@@ -151,7 +202,7 @@ Event BeginPlay
|
||||
OnOverlapBegin (Player overlaps InteractionCollision)
|
||||
→ Set VisualState = Highlighted
|
||||
→ Show pickup prompt widget (if assigned)
|
||||
→ Cache player's BPC_InventoryComponent
|
||||
→ Cache player's BPC_InventorySystem
|
||||
|
||||
OnOverlapEnd (Player leaves InteractionCollision)
|
||||
→ Set VisualState = Idle
|
||||
@@ -163,7 +214,7 @@ Interact_Implementation (Called from BPC_InteractionDetector)
|
||||
→ Validate player inventory has space → if full, show "Inventory Full" feedback → return
|
||||
→ Set VisualState = BeingPickedUp
|
||||
→ Play pickup sound + particle effect
|
||||
→ Call BPC_InventoryComponent.AddItem(Config.ItemData, Config.Quantity)
|
||||
→ Call BPC_InventorySystem.AddItem(Config.ItemData, Config.Quantity)
|
||||
→ If AddItem succeeded:
|
||||
→ Broadcast OnPickupCollected(InteractingPlayer)
|
||||
→ If bIsInfinite → do not destroy
|
||||
@@ -214,12 +265,12 @@ OnRespawnComplete
|
||||
|--------|--------------|
|
||||
| `I_Interactable` | Implements the interface for interaction detection. |
|
||||
| `BPC_InteractionDetector` | Sends overlap events and routes interaction call. |
|
||||
| `BPC_InventoryComponent` | Target for item addition. |
|
||||
| `DA_ItemData` | Supplies mesh, name, icon, stack limits. |
|
||||
| `BPC_PlayerMetricsTracker` | Logs pickup event (item type, quantity, location). |
|
||||
| `BPC_InventorySystem` (31) | **Target for item addition.** C++ component — call `AddItem(ItemData, Quantity)`. |
|
||||
| `DA_ItemData` (07) | Supplies mesh, name, icon, stack limits, weight. |
|
||||
| `BPC_PlayerMetricsTracker` (15) | Logs pickup event (item type, quantity, location). |
|
||||
| `I_Persistable` | Optional: saves pickup state (available, transform, quantity). |
|
||||
| `BPC_InventoryWeightSystem` | Checks weight capacity before allowing pickup. |
|
||||
| `BPC_AdaptiveDifficulty` | May adjust item availability based on difficulty. |
|
||||
| `BPC_KeyItemSystem` (34) | Checks `bIsKeyItem` — key items auto-protect from drop/clear. |
|
||||
| `SS_AchievementSystem` (103) | Notified on collectible pickups for completion tracking. |
|
||||
|
||||
---
|
||||
|
||||
@@ -248,7 +299,7 @@ Player approaches world item → Overlap event
|
||||
Player presses Interact key
|
||||
→ BPC_InteractionDetector.InteractTarget → BP_ItemPickup.Interact_Implementation
|
||||
→ Validate availability + inventory space
|
||||
→ BPC_InventoryComponent.AddItem (ItemData, Quantity)
|
||||
→ BPC_InventorySystem.AddItem (ItemData, Quantity)
|
||||
→ Play pickup sound + particle
|
||||
→ Broadcast OnPickupCollected
|
||||
→ If bRespawns → StartRespawn (hide, wait, reappear)
|
||||
|
||||
Reference in New Issue
Block a user