BPSC_LPSP_Inventory

Introduction

The Inventory Component (BPSC_LPSP_Inventory) handles the updating of equipped items, their spawning, and other related tasks.

If you seek to access the BPSC_LPSP_Inventory, it is conveniently located at the following path: InfimaGames/LowPolyShooterPack/Core/Inventory/BPSC_LPSP_Inventory.

Editable Variables

Equipped Index At Start:

This value represents the index used from the inventory array as the starting equipped item.

Starting Items:

Items spawned when the game starts and added to the inventory.

Inventory Capacity:

Maximum amount of items that the inventory can hold.

Can Drop Items:

If true, the inventory can drop items.

Dropping Force:

Force applied to items when dropping them.

Dropping Force Angular:

Angular force applied to items when dropped.

Initial Unholster Delay:

Delay before unholstering the equipped weapon at the start of the game.

Show Unarmed Arms:

This variable controls the visibility of the character's arms when no item is equipped. If true, the unarmed arms will be displayed.

Use Unarmed State Animations:

If true, this variable allows the character to use specific animations associated with an unarmed state.

Private Variables

Inventory:

This is an array of all the currently equipped items. We use it to reference and sometimes swap between them. This is a very important variable!

Equipped:

This refers to the item that the character currently has in their hands or has equipped.

Pawn Owner:

This component is owned by a pawn. We assume this because it wouldn't make sense for an inanimate object to have this kind of inventory. While this assumption may not always be accurate, it is generally a reasonable one.

Holster State:

This variable represents the character's holstering state, as known by the inventory. In simpler terms, it indicates whether the character's equipped item is holstered or not.

Started:

This is a helper variable that indicates whether we have already gone through the initial inventory process, which means that Begin Play has been executed at least once.

Fully Holstered:

If this variable is true, it means that the equipped item is fully and properly holstered. This is crucial for some of the unholstering functionality.

Swapping Ability:

The SGameAbility determines how item swapping works in the game. While it would be ideal to have this ability grouped with all other item abilities, for the time being it works fine on its own.

Unholster Name:

This value indicates the name of the current unholster montage to be used by the inventory component. Although this changes frequently during gameplay, we need to keep it as a variable for replication purposes.

Holster Name:

This value indicates the name of the current holster montage to be used by the inventory component. Although this changes frequently during gameplay, we need to keep it as a variable for replication purposes.

Spawned Initial:

If this variable is true, it means that all items have been spawned, and the inventory is ready for other actions to take place.

Refresh Unholster:

This variable is a bit of a "hack" that we toggle to unholster in a Rep Notified manner.

Equipping Holster:

If this is true, the next time you try to equip an item, it will first play the holster animation for the currently equipped item before unholstering the newly-equipped item.

Equipping Item:

This variable represents the index of the item that will be equipped next in the Inventory array. We mostly need this variable to clean up the blueprint, rather than actually needing it for functionality.

Changing Items:

This variable is set to true every time the component is running some sort of item-changing functionality. This is very helpful in case the component's owner needs to know this information.

Equipped Properly:

This variable ensures that we run certain equipment-related functions only once, regardless of the number of times or the number of clients to which we replicate the equipping functionality.

Functions

Get Inventory:

This function returns an array of items held in the inventory.

Equip Item:

Equips the item passed to the function as the currently equipped item.

Has Space:

Returns true if there's still available slots in the inventory.

Try Pick Up Item:

Tries to pick up an item into the inventory.

Get Previous Item Index:

Returns the index of the previous item in the inventory array.

Get Next Item Index:

Returns the index of the next item in the inventory array.

Get Equipped Index:

Returns the index of the item equipped in the inventory array.

Try Drop Equipped:

Tries to drop the currently equipped item.

Get Equipped:

Returns the equipped item.

Get Pawn Owner:

Returns this component's pawn owner.

Get Holster State:

Returns the current holster state.

Get Name Montage Holster:

This function returns the name of the Montage holster that should be played. It is useful in determining when to play a smooth holster versus a normal, full holster.

Get Name Montage Unholster:

This function returns the name of the Montage unholster that should be played. It is useful in determining when to play a smooth holster versus a normal, full holster.

Get First Person Mesh:

Returns the first-person character arms mesh.

Get Third Person Mesh:

Returns the third-person character arms mesh.

Try Start Holster Ability:

Tries to start the holster ability on the owner.

Stop All Owner Montages:

Stops all montages playing on the owner's mesh and equipped item.

Spawn Initial Items:

Spawns all the initial items that should be equipped.

Drop Equipped:

Drops the equipped item.

Try Equip Item Added:

Tries to equip an item that is Added away from the equipped index.

Is Changing Items:

This function indicates whether the inventory is currently undergoing a change in items.

Get Fully Holstered:

This function returns the value of the "Fully Holstered" variable. It indicates whether the equipped item is currently fully holstered, meaning the character has finished playing its holster animation for that item.

Set Starting Items:

This function allows us to determine the inventory's initial set of items to spawn. These are essentially the items that the owner starts with.

Add Item To Inventory:

This function allows for the addition of a new item to the inventory.

Local Equip Next Item:

This function enables the character to equip the next item in the inventory array, useful for switching items during gameplay.

Throw Equipped Item:

This function lets the character throw or discard the currently equipped item, removing it from the inventory.

Set Unarmed:

This function allows the character to unequip all items, essentially setting the character to an unarmed state.

Try Remove Fade Widgets:

This function attempts to remove any fading widgets, typically used for HUD elements that fade out over time.


Last updated

Was this helpful?