Adding Items from Pickups
Items can be added to the inventory through actors placed in the world, typically representing loot, rewards, or interactable pickups.
While the Inventory system provides a ready-to-use base actor class (ANinjaInventoryPickupActor), the only requirement is that your actor implements the IInventoryPickupInterface.
The Inventory Manager provides a built-in function, AddItemsFromPickupActor, which can be used to extract and grant items from any actor that implements this interface. This ensures custom pickup actors remain fully compatible with the inventory system’s queuing, stacking, and placement logic.
This gives you full control over how pickups behave, while still benefiting from the Inventory system’s item lifecycle and automation.
Provided Pickup Actor
Adding Items from a Pickup Actor
Create a new Actor that inherits from ANinjaInventoryPickupActor.
Customize the actor visually and functionally using meshes, effects, audio, or any other components relevant to your game.
In the actor's
PickupItemsarray, define one or more default items that should be granted when the pickup is collected.
Custom Pickup Actor
If you'd like to build a custom pickup actor (e.g., for complex interactions, scripted behavior, or special effects), you can do so by implementing the IInventoryPickupInterface.
This allows you to define your own collection logic while still leveraging the Inventory system’s item creation, queuing, and placement handling.
Implementing a Custom Pickup Actor
Create a new actor based on your desired class (e.g., derived from
AActoror any custom base).Implement the IInventoryPickupInterface on your actor class.
Add a property that stores an array of
FInventoryDefaultItementries. This defines the items that can be granted to the inventory.Implement the required interface functions:
GetPickupItemDefinitions: returns the current array of item definitions.SetPickupItemDefinitions: allows updating the array programmatically.
Implement your pickup logic. When ready to grant the items, call
AddItemsFromPickupActoron the target's Inventory Manager.