Just wanted to ask how others go about deleting spawned actors in a streamed level when unloading that level.
At the moment, when I spawn an actor inside a streamed level and then unload that level, the spawned actors remain. I’m just not sure on a good way of going about deleting any spawned actors in a streamed level when unloading that level.
Hey, had exactly the same problem. Two things to know:
When you spawn an actor, it actually appears in the persistent level, that’s why it’s still there after level unload.
When you spawn an actor, you have to set the ‘owner’ pin to something in your level. That way, when the system unloads your level, it knows to kill the actors because they belong to someting in that level
So I tried what you mentioned in regards to the owner pin, but for whatever reason it didn’t work for me. However, I was able to find another work around which is working well. Since my streaming levels are basically an interior to a house/building, I was able to just use a box collision (covering the whole level - house/building) and check any actors overlapping with that and then destroying them just before unloading the level.
Yeah I tried several actors that are only in the map and still didn’t work. The way I have it now is probably easier in my case since there are many ways an item can be spawned and I didn’t want to go changing code all over the place. The actors I want to destroy all come from a single master item so it made the way i’m doing it now even easier.
I’m very new to streaming levels, so still learning as I go.
The Solution that they explained worked for me. What I did was set up all of my Spawn BP nodes within the Streamed Level BP. The SpawnActor Node has a pin that asks for an owner. All you have to do is put a reference to Self, in this case that would be referencing the entire streamed level itself. Then, when that Streamed Level is unloaded, the Spawned Objects will automatically unload as well. Piece of Cake!
If you are unloading spawned things across levels (you’ve only hid your level to keep certain things), then using an interface is the perfect solution.