Grenade bug

arenoo

Member
When the last grenade is thrown and it damages a player a NullReferenceException is thrown. Reproducible in the demo scene. This is happening because in PunHealthMonitor at line 72 (sourceItemIdentifierID = itemAction.CharacterItem.ItemIdentifier.ID;) the itemIdentifier is null at the time of explosion. And that is because the CharacterItem.ResetInitialization is called before the actual explosion. How can I fix this?
 
Thanks, I will take a look for the next PUN update.
I've encountered the same issue, I'm not entirely sure whether it's a bug or simply an incorrect implementation on my end. Essentially, what's happening is that we have a Grenade pickup configured with a capacity of one. After the player throws the grenade, the item is correctly removed from their inventory and the player prefab, the ItemIdentifier assigned null? When the explosion on damage is called the ItemIdentifier is null?

Code:
 INetworkHealthMonitor.OnDamage(args)
 if (itemAction != null)
 {
     sourceItemActionID = itemAction.ID;
     sourceSlotID = itemAction.CharacterItem.SlotID;
     sourceItemIdentifierID = itemAction.CharacterItem.ItemIdentifier.ID;
 }
 
the item is correctly removed from their inventory and the player prefab, the ItemIdentifier assigned null?
That is the correct understanding.

It looks like I missed this one the PUN updates. I'll need to trace through it and will get back to you on the fix.
 
Within InventoryBase on line 1186 remove the following:

Code:
characterItem.ResetInitialization();
This will prevent the ItemIdentifier from being set to null when the item is removed. I'll include this in the next update.
 
Within InventoryBase on line 1186 remove the following:

Code:
characterItem.ResetInitialization();
This will prevent the ItemIdentifier from being set to null when the item is removed. I'll include this in the next update.
Thank you very much!
 
characterItem.ResetInitialization();
I can confirm that the issue is now 100% resolved. I tested it thoroughly (including by accidentally blowing myself up!), and everything is working perfectly with no errors.

Thanks again for the help!
 
Back
Top