How can I spawn an actor as owned by a particular streaming level?

I’m trying to spawn actors inside a certain streaming level, and I need to make them “children” of that level, so that when it unloads, the actors go with it.

How do I do that in blueprints?

The documentation shows there’s an OverrideLevel option for the SpawnActor function, but it’s not exposed in blueprints for some divine reason. I don’t want to use C++.

Thanks.

1 Like

In the fold out details of the spawn node, you get to set the owner. As long as the owner is set to something that is actually from the level, when the level unloads, the actor will get destroyed.

Otherwise, by default, everything is spawned in the persistent.

1 Like

What if the level is empty, though?

Are there any “default” actors I can rely on to always be there, in a level?

And what if I have multiple levels loaded at the same time? How can I get one actor from a specific loaded level?

1 Like

Just put an actor BP in the level, and you can say ‘hey, that spawned this’ :slight_smile:

I think even just a reference to a static mesh would do the trick ( not sure, haven’t tried ).

1 Like

Make it the spawner.

1 Like

Thanks, it thought about it, but I was hoping there’s a more professional solution.

I guess, I have to do the workaround. Thanks again.

But wait, what if I have multiple streaming levels loaded at the same time? I’ll have multiple of those “spawner” actors. How do I know to which level each belongs?

How about creating a Game Instance BP, and storing each spawner’s reference there? You can hardcode a string variable with a specific name pertaining to that level, since the game instance reference can be called anywhere, you’ll have a reference to whichever spawner you want at your virtual fingertips

So you mean creating a string var in the spawner actor, and dropping that actor in each of my levels? But how would I reference those actor instances in the game instance?