Scene Graph inventories: can't add item when a child entity of the item has an inventory_component

Summary

An item entity can’t be added to an inventory if any entity below it (child or grandchild) has an inventory_component. inventory_component.AddItem and CanAddItem return 1 add_item_error, which Verse can’t read (no fields, not castable, no public subclasses). The same item without the child entity is added fine. Nothing is logged in the editor or client log, and no find_inventory_event / add_item_query_event reaches any inventory, so the refusal happens before the query phase.

Please select what you are reporting on:

Unreal Editor for Fortnite

What Type of Bug are you experiencing?

Scene Graph

Steps to Reproduce

  1. Create a blank UEFN project (43.10). Add “Custom Items and Inventory”.
  2. Add the Verse file below, build Verse, and place the device in the level.
  3. Launch a session and start the game.
  4. After 3 seconds, read the Verse log.
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Itemization }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }

# Repro: AddItem fails when a child entity of the item has an inventory_component.
child_inventory_repro_device := class(creative_device):

    OnBegin<override>()<suspends>:void =
        Sleep(3.0)  # wait for the player
        for (Player : GetPlayspace().GetPlayers(), Root := GetRootInventory[Player]):
            # Target: a plain inventory in the scene, under the player's root inventory
            TargetEntity := entity{}
            Target := inventory_component{ Entity := TargetEntity }
            TargetEntity.AddComponents(array{ Target })
            Root.Entity.AddEntities(array{ TargetEntity })

            # Control: a plain item
            Control := NewItem()
            TryAdd(Target, "Control: item only", Control)

            # Bug: the same item with one child entity holding an inventory_component
            Bug := NewItem()
            Child := entity{}
            Child.AddComponents(array{ inventory_component{ Entity := Child } })
            Bug.AddEntities(array{ Child })
            TryAdd(Target, "Bug: item + child entity with inventory_component", Bug)

    # The player's root inventory: the first child entity of the agent with an inventory_component
    GetRootInventory(Agent:agent)<transacts><decides>:inventory_component =
        for (Child : Agent.GetEntities(), Inv := Child.GetComponent[inventory_component]) { Inv }[0]

    NewItem():entity =
        Item := entity{}
        Item.AddComponents(array{ item_component{ Entity := Item } })
        Item

    TryAdd(Target:inventory_component, Label:string, Item:entity):void =
        Result := Target.AddItem(Item)
        if (Result.GetSuccess[]):
            Print("[repro] {Label}: added")
        else if (Errors := Result.GetError[]):
            Print("[repro] {Label}: FAILED, AddItem returned {Errors.Length} add_item_error(s)")
        else:
            Print("[repro] {Label}: FAILED")

Expected Result

Both items are added to the target inventory. If this structure isn’t supported, the error should say why (a readable add_item_error subclass or message), and the Inventory Component docs should mention the restriction.

Observed Result

[repro] Control: item only: added
[repro] Bug: item + child entity with inventory_component: FAILED, AddItem returned 1 add_item_error(s)

Platform(s)

PC, 43.12

Additional Notes

Narrowed down in the same project:

  • CanAddItem already refuses the item (1 error); AddItemDistribute fails too.
  • An inventory on a grandchild fails the same way.
  • An inventory_component on the item’s own entity works: such a bag can hold plain items, move between inventories, be dropped and be added again.
  • A loose child entity with only an item_component (not held by any inventory) also fails.
  • Attaching the child inventory after the item is in an inventory works, and Drop works, but the dropped item can’t be added again.
  • A bag holding another bag (item + inventory) holding an item can be built in place, but once the outer bag is dropped it can’t be added again.
  • In another project, the Fortnite pickup (fort_item_pickup_interactable_component) on such an item did nothing: the target inventory’s find_inventory_event handler was rolled back and no add query followed.

Why it matters: an entity can hold only one inventory_component, so a bag with several compartments (e.g. pockets of different sizes) needs extra inventories on child entities. Today such a bag can be built in place but can never be picked up, moved or re-added after a drop.