Problem with events

Szymon Z.

Member
Hello :)

I read the documentation but i still have problems with events, after couple of hours i still don't understand how it works...

We have an event called: OnInventoryPickupItem.

I know the signature, it's working fine when i'm trying to assign that in inspector. But now i want to RegisterEvent via a script. And... that part won't work ;)
I have no idea if i need any parameters at the start or not, what type of parametr should that be.

1625464686012.png

Maybe it's part of CharacterController, i don't know that, i tried with Inventory from UCC (not working, because i dont have an inventory on the scene from UCC after integrations), i tried with Inventory from Ultimate Inventory => still no luck. Is somewhere any explanation how we should use those events, what should be parameter/listener ? Documentation is not clear about that part. It costs a lot of hours to identify what kind of parameters and from which package should have every event...
 
This page explains all the UCC events: https://opsive.com/support/document...ller/programming-concepts/events/event-names/

For the UIS events you can find them in your project under EventNames.cs.

This page explains how the event system works: https://opsive.com/support/documentation/ultimate-character-controller/programming-concepts/events/

In the case of UCC events most target the character gameobject not the Inventory component.
When you aren't sure what the Target or parameters types are for an event I would recommend you do a ctrl+shift+F to find all the places where the event name is being used. Then find where it is being Executed and check what the target and parameters are.

I hope that helps
 
Yeah i saw that page, but even copy-paste some code causes problem... when i'm using GameObject like on samples (for example Equip/Unequip Ability) that is an null reference exception there:

1625466107662.png

m_GameObject is not null,
item is not null,
amount is not null,
immediatePickup is not null
forceEquip is not null

so... i have no idea what can cause null reference there, it's why i thought i should use some kind of inventory instead of player gameobject :)
 
I found the problem, the signature in inspector is requiring type Single as amount while event is sending int, so register also should have int instead of Single...
 
Top