Problem making event listener for "OnInventoryUseItemType"

treshold82

New member
Hi!

I have bit problems understanding TPC internal event system. I followed example from documentation about OnImpact event and I managed to get it work but when I would like to hook up to OnInventoryUseItemType, I can't get it work.
Here is simple script made along the documentation:

Code:
public void Awake()
    {
           EventHandler.RegisterEvent<ItemType, int>(gameObject, "OnInventoryUseItemType", OnUsedItem);
    }
    
    public void OnUsedItem(ItemType item, int count)
    {
       Debug.Log("inventory used:" + item.name + " amount: " + count);
    }

If I put this script to playercharacter and I shoot arrow for example, I don't get debug.log message to console.
What I am missing?
 
As long as gameObject points to the GameObject that has the inventory component on it then that event registration looks correct. You can see an example of this event subscription within the ItemMonitor.
 
As long as gameObject points to the GameObject that has the inventory component on it then that event registration looks correct. You can see an example of this event subscription within the ItemMonitor.

Thanks, I'll check the ItemMonitor and debug my stuff. Cheers.
EDIT. after looking ItemMonitor, i got it working :)
 
Last edited:
Top