[Itemization] Moving an item out of a player inventory removes a different item from the scene

Summary

Verse: inventory_component.AddItem moving an item out of a player’s inventory silently removes a different item under that player from the scene

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

  1. Create a blank UEFN project (43.12) and turn on Project Settings > “Custom Items and Inventory” (without it the player has no root inventory).
  2. Add the Verse device below, place it in the level, push changes and start the match with one player.
  3. The device runs by itself from OnBegin (no pickups or input):
    • creates two plain inventory_components (P1, P2) as children of the player’s root inventory,
    • adds three plain items (entities with only an item_component) to each,
    • creates one inventory_component (W) under the simulation entity (in the world),
    • calls W.AddItem(P2#2), waits 1 s, then W.AddItem(P1#2),
    • prints where every item is after each step.
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Itemization }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }

(Agent:agent).GetInventoryRoot()<transacts><decides>:inventory_component =
    (for (Child : Agent.GetEntities(), Inv := Child.GetComponent[inventory_component]) { Inv })[0]

additem_repro_device := class(creative_device):
    OnBegin<override>()<suspends>:void =
        Sleep(3.0)
        if (Sim := GetSimulationEntity[], Player := GetPlayspace().GetPlayers()[0], Root := Player.GetInventoryRoot[]):
            W := NewInventory(Sim)
            P1 := NewInventory(Root.Entity)
            P2 := NewInventory(Root.Entity)
            A := Fill(Sim, P1)
            B := Fill(Sim, P2)
            Sleep(1.0)
            Print("filled:        P1 {Brief(A, P1)} | P2 {Brief(B, P2)}")
            if (X := B[2]) { W.AddItem(X) }
            Print("moved P2#2->W: P1 {Brief(A, P1)} | P2 {Brief(B, P2)}")
            Sleep(1.0)
            if (X := A[2]) { W.AddItem(X) }
            Print("moved P1#2->W: P1 {Brief(A, P1)} | P2 {Brief(B, P2)}")

    NewInventory(Parent:entity):inventory_component =
        E := entity{}
        Inv := inventory_component{ Entity := E }
        E.AddComponents(array{ Inv })
        Parent.AddEntities(array{ E })
        Inv

    Fill(Sim:entity, Inv:inventory_component):[]entity =
        for (N := 1..3):
            Item := entity{}
            Item.AddComponents(array{ item_component{ Entity := Item } })
            Sim.AddEntities(array{ Item })
            Result := Inv.AddItem(Item)
            Item

    Brief(Items:[]entity, Inv:inventory_component):string =
        Parts := for (Item : Items):
            if (IC := Item.GetComponent[item_component], P := IC.GetParentInventory[], P = Inv) then "in"
            else if (IC := Item.GetComponent[item_component], IC.IsInScene[]) then "out"
            else "GONE"
        "[{Join(Parts, ", ")}] ({Inv.GetItems().Length})"

Expected Result

Only the item passed to AddItem changes inventory. Every other item stays where it is. (The digest describes AddItem as “Adds the item to this inventory only”.)

filled: P1 [in, in, in] (3) | P2 [in, in, in] (3)
moved P2#2->W: P1 [in, in, in] (3) | P2 [in, in, out] (2)
moved P1#2->W: P1 [in, in, out] (2) | P2 [in, in, out] (2)

Observed Result

Each AddItem succeeds and moves its item into W, but also takes one OTHER item under the player out of the scene: its GetParentInventory, entity.GetParent and IsInScene all fail, and RemoveItemEvent on the player’s root inventory fires twice. The first move lost P1#0, the second P2#1.

filled: P1 [in, in, in] (3) | P2 [in, in, in] (3)
moved P2#2->W: P1 [GONE, in, in] (2) | P2 [in, in, out] (2)
moved P1#2->W: P1 [GONE, in, out] (1) | P2 [in, GONE, out] (1)

(in = in that inventory, out = moved to W, GONE = no longer in the scene; the number is GetItems().Length)

Platform(s)

Windows PC (UEFN 43.12, ++Fortnite+Release-43.12-CL-60598086; play-in-client session)

Additional Notes

Workaround:
No loss when the item is removed first (P2.RemoveItem(X), then W.AddItem(X)), dropped first (item_component.Drop), or moved into another inventory under the same player.
if (Src.RemoveItem(X).GetSuccess, Dst.AddItem(X).GetSuccess) { … }

  • Inventory configuration: BR or empty

  • The same moves between two inventories that are both in the world lose nothing.

  • Also happens with prefab items using fort_item_pickup_interactable_component, with inventory_component subclasses, and with held_item_template{} items (one lost on the second move). shotgun_template{} items lost nothing (one run).

  • Not related to stacking (?AllowMergeItems := false, ModifiedItems empty) or equipping (no item was equipped).

  • The lost item isn’t destroyed: calling AddItem on it later puts it back.

  • Possibly related, but a different symptom: [Itemization] Removing items from inventories still leads to wrong unexpected behaviors. (FORT-1120114, “addressed in 44.00”). That thread is about wrong events for the moved item; here a different, untouched item leaves the scene.