Any way to destroy dynamically spawned actors automatically on level unload?

I’m spawning some actors at runtime and I want them ‘belong’ to a level so that they get destroyed when the level is unloaded. Anyone know how to do that?

One idea: Store a reference to these actors, then in GameInfo.GameEnding(), clean them up.

That’s a good idea. Thanks. But I don’t think that function would ever get called for me… when does GameEnding() get called? In my game, the player might be in a town level, and there the player would use a door, which streams in the castle map, where I might spawn an item that the player can pick up. But then if the player goes back to the town level (and unloads the castle level) without picking up the item, I’d like the item to get deleted. Does GameEnding get called every time you unload a streaming level?

Oh, I’ve never used level streaming. I imagine there must be some events from when a level is streamed in and out though…

On a quick glance, there is this in PlayerController.uc:

final event LevelStreamingStatusChanged(LevelStreaming LevelObject, bool bNewShouldBeLoaded, bool bNewShouldBeVisible, bool bNewShouldBlockOnLoad )