Summary
When using ItemComponent.ChangeInventoryEvent to detect inventory changes for that item, it is not behaving as it is supposed to, making the usage unstable in certain scenarios and even unusable in other specific cases.
Please select what you are reporting on:
Verse
What Type of Bug are you experiencing?
Scene Graph
Steps to Reproduce
- Make a custom item prefab using this example item_component setup (Do the test with an item made from scratch and also with an custom item subtype based on an existing fortnite weapon prefab):
my_item_component<public> := class<final_super>(item_component) {
var<private> InventoryItemEventSubscriptions<private> : ?cancelable = false
OnSimulate<override>()<suspends>:void = {
option{
not InventoryItemEventSubscriptions?
set InventoryItemEventSubscriptions = option{
Self.ChangeInventoryEvent.Subscribe(OnInventoryChanged)
}
}
}
OnInventoryChanged<private>(ChangeInventoryResult:change_inventory_result):void = {
Print("On Inventory Changed Event: " + ToDiagnostic(ChangeInventoryResult))
Print(" ↪ Previous: " + ToDiagnostic(ChangeInventoryResult.PreviousInventory))
Print(" ↪ Current: " + ToDiagnostic(ChangeInventoryResult.CurrentInventory))
}
}
- Spawn the item in game
- Do actions such as picking it up and dropping repeatedly
3.1 Also, do actions such as removing and reading to the world/scene (without messing with inventories) - Observe the results printed on the logs
Expected Result
change_inventory_result should behave:
- correctly have the current AND previous inventory when applicable
- fire only on inventory related changes
- fire only a single time on each change that happened
Observed Result
change_inventory_result is currently behaving:
- the
PreviousInventoryis always empty making it useless. Ex. if you drop an item from inv to the ground, both thePreviousInventoryandCurrentInventorywill befalse. (Previous expected to be the inventory from which it was dropped) - It is firing every time on any scene changes, including adding/removing to scene. Behaving more like a “SceneChangedEvent” instead of a “ChangeInventoryEvent”.
- It is firing multiple times (probably delated to item 2 mentioned above). Sometimes even 3x or more.
Platform(s)
All (Verse/Server)
