How to interpret User Collection Objects as Inventory Items

This page will help you understand how to configure and interpret ownership of user collection objects so that items can be given to player inventories.

Overview

This feature you allows to configure what inventory items should be given to players due to the ownership of user collection objects. An example of this used in practise would be avatar inventory items given to players as a result of owning certain user collection objects. Possible use cases:

  • Interpreting user collection content for custom use cases - User collection objects with image content could be used as decals on a wavable flag.

  • Persisted consumable items - Items that if used in game will reduce the balance of a user collection object.

Integration

Interpretting user collection objects as inventory items can be done using a custom component. This component can be configured on JM_CharacterBase on the User Collection Inventory Component Class property. By default, an example component BPC_M2_UserCollectionInventoryComponent is set on BPM_M2_PlayerCharacterBase. If your Morpheus player character derives from this class, you will be using this configuration by default.

You will most likely want to override this property with your own component class. Let's work out how to create your own user collection inventory component! There are two method you will likely want to go down: deriving from our example component with some configuration or creating a custom component.

Creating a component that derives from BPC_M2_UserCollectionInventoryComponent and then configuring the new components properties might be the easiest solution for you. BPC_M2_UserCollectionInventoryComponent offers the capability to:

  • Map an object uid to a specific item using the UidToItemMapping property.

  • Map an object uid to a specific item that when removed from the inventory, reduces the balance of the corresponding object. This can be acheived configuring DirectRelationshipItemsMapping.

  • Configure a default item to be used for all other "unhandled" user collection objects using the DefaultUserCollectionItem property.

  • Configure which item is added to the inventory for the ownership of MML and avatar user collection objects. Relevant properties are: MMLDeviceItem, MMLDeviceObject, AvatarObjectItem and AvatarAssetObjectItem.

If some functionality you need is not offered by BPC_M2_UserCollectionInventoryComponent, we recommend deriving from BP_BaseUserCollectionInventoryComponent as it can also be a useful starting point. BP_BaseUserCollectionInventoryComponent has a virtual function GetItemNameForObject that you can override so that you can map objects to inventory items however you like.

Using User Collection Object Data in Inventory Items

In some cases, inventory items need to read meta data on user collections objects in order to customize their behaivour when used. An example of this is our example flow AvatarObjectItem flow. This flow involves giving players an item representing an avatar asset owned in the user collection. This item can be used to equip a wearable. When the item is used, we grab the user collection object that granted the inventory item and use the object's data to inform what wearable to equip. 1. On BPC_M2_UserCollectionInventoryComponent, AvatarObjectItem is configured so that the PDA_Item_UserCollection_Avatar item is added to the player inventory for user collection objects that are known avatar objects. 2. PDA_Item_UserCollection_Avatar has an executor called: BP_ItemExecutor_ChangeAvatar. 3. Inside BP_ItemExecutor_ChangeAvatar, GetUserCollectionObjectFromItemKey is used to get the user collection object data. This data is then used by the modular character component to load the correct avatar.

How to enable

By default, the feature is enabled if using the BPM_M2_PlayerCharacterBase. If you wish to disable the feature, just ensure the User Collection Inventory Component Class property is set to None on your morpheus player character class.

Last updated