Unable to add levels to some projects

When I try to add a new level to the project I made to complete Code a First-Person Adventure Game, Unreal Engine crashes consistently. However, when I use the same template (first person, Arena Shooter variant) to create a new project and add a level to it, Unreal Engine doesn’t crash. The attached screenshot shows some of what I see after it crashes.

I was able to create a new level (a basic level, the same kind of level I attempted to create when I experienced crashes) in the example project available on the website shown in this screenshot.

Hi there, thanks for reporting this bug! To fix your project:

  1. Open PickupBase.cpp and change line 110-111 from this:
// Create a copy of the item with this class as the owner
ReferenceItem = TempItemDefinition->CreateItemCopy(this);

to this:

// Create a copy of the item with transient package as the Outer so the item can be safely stored long-term in inventory
ReferenceItem = TempItemDefinition->CreateItemCopy(GetTransientPackage());
  1. Rebuild your code.
  2. Delete all existing pickups from any levels you worked on during Code a First Person Adventure Game. Save the level(s).
  3. Close and re-open either the level or the editor to clear any remnants from these broken pickups from memory.
  4. Open the editor and/or your level again and add new pickups if desired (add BP_PickupBase actors and use their Details to pull items from your data tables).
  5. Try to create a new level.

CreateItemCopy(this) in PickupBase::InitializePickup() used the level-placed Pickup actor as the new item’s Outer, but that item copy gets handed off and stored long-term in the player’s InventoryComponent once picked up. Since the copy keeps its Outer alive by design, and Unreal Engine treats duplicated Data Assets as RF_Standalone (an unconditional GC root), the still-alive copy keeps a live reference back to the old Pickup actor (and thus its Level/World) even after the level should unload, causing a “World Memory Leak” crash the next time you open or create a level. Using GetTransientPackage() as the Outer instead fixes it because the transient package has no level affiliation, so the copy’s Outer chain no longer ties it to a level that needs to unload.

We’ve updated the tutorial with this fix as well!