For the player to be able to interact with any object (slimes, benches, bushes) they need to have an Interactable component attached.
The PlayerInteractionFinder
script uses a Raycast from the player Transform to detect any Gameobjects with Interactable components. When it finds one it triggers the StartLookingAt()
UnityEvent on the Interactable
script which activates the InteractionsViaInputActions
script, this script handles the UI prompt, the interaction triggering and the button prompts.
The Interactable.cs
, PlayerInteractionFinder.cs
, and InteractionsViaInputActions.cs
all use the Interaction class. Let's break down what that class contains.
Interaction Name
Item To Receive
Item Base
OnInteraction (ItemStack)
and OnInteractionDone()
isBlocked