Creating new interactions

Let's create a new simple pick-up interaction, that will use Inventory System.

  1. Create a new script. For more convenience end it with Interactable or Interaction.

  1. Extends from Interactable

You will see red line, which indicate that scripts contains errors. That's right, once we extend from Interactable, we need to implement some base methods.

  1. Implementing required methods

We only need primary action for this interaction, so we set UsePrimaryActionHint() to return true, and also make GetPrimaryHintText() return hint text "Pick object".

For UseSecondaryActionHint() and GetSecondaryHintText() we return default values.

Also, we need to override IsUnsubscribeBlocked(), but, because we don't want to block interaction, we return false.

  1. Now, let's override OnInteractPrimary() and add some logics to it.

Also, we created a new field, inventoryItemData to set it from inspector.

  1. Ok, we have created script. Now, let's setup it in Unity

Create new gameobject, or drop from project tab.

circle-exclamation

Change layer, from default to Interactable

Add Outline component to object, and disable it (we don't need that outline to be visible at start)

Finally, add our interaction PickUpInteractable, and set inventory item data with and corresponding item

circle-check

Last updated