How do I unload an instanced level?

Promote to variable return value from load level instance and when needed just set ShuoldBeLoadded from with variable to false

I’m generating a procedural city block-by-block (city blocks, I mean, not voxels or anything). I’m using overlapping Trigger Volumes to Load Instanced Levels of my map, which is currently one city block with tons of randomized components.

My problem is that I can’t figure out how to Unload the levels after leaving the trigger volume. I assume I would want to assign a unique name or ID to each level as it spawns, but I can’t quite figure out how to do that. Ideally, each trigger volume would spawn the same level each time, but right now it’s spawning levels on top of each other and not despawning anything.

If I understand correctly, you need something like this:

At the output, you will get in printstring "path to your main level/UEDPIE_0_Your instance name

I believe that worked, but how can I test that it’s the same Level ID? The level definitely spawns and despawns correctly, but I’m using procedural maps so it’s hard to tell if I’m getting the SAME level. Is there a way to turn the Level ID into a string so I can print it? It’s a Level Streaming Kismet object reference.

This is what I mean, every time the map loads and reloads, it gets mixed up. I’m guessing this is also possibly because I have my generation in the Construction Script. Would I need to swap it all over to the Event Graph and just make it all “On Event Begin Play”?

Also, if buildings randomly generated, you can try use random from stream, and get stream value from level instance coordinate

I actually managed to figure it out. I did Create Instance in the Construction Script and assigned a name of the spawn volume’s XY coordinates as a unique ID. Then in the Event Graph, I simply did a toggle of “Should be loaded/ should be visible” targeting a Set Variable from the output of the Create Instance. This apparently works even if all of the procedural generation is done in the actor’s Construction Script (tested using randomly generated buildings).

False alarm, so I tested my idea out on a map that just consisted of an individual building. It spawned the same every time. When I went back and tried it with a city block (just layers of procedural buildings and stuff), it no longer retains any consistency. So my core problem of loading and unloading levels is resolved, but now I have to try to figure out how to keep the levels from being re-mixed every time they get loaded/unloaded.