Give item to player

irilox

New member
Hi,

I created a chest. When the player is interacting with it it instantiates one or more itempickup prefabs (that the player can walk to and pickup).
But I would like to give the items immediately to the player instead of instantiating the itempickups.

What would be the best way to do this?

My idea was to still use my script (that is based on IInteractableTarget) and copy some code from the scripts ItemPickup and ObjectPickup.
I wouldn't use the OnTriggerEnter() but then I need a reference to the character that is interacting. But it seems that the interacting system isn't passing thru a reference of the interacting character. Am I correct?
Or is there maybe a better way to do this?
 
Thanks Justin.
I worked it out with inventory.PickupItemType() and inventory.AddItem().

But instead of setting manually the reference to the character (with
[SerializeField] protected GameObject m_Character; ) I would like to detect on my IInteractableTarget which character is interacting with my chest (this could be the player or a NPC).
If I'm correct there is at this moment no possibility to know which character is interacting with the IInteractableTarget.
 
Top