Download

Is there a function or event that gets called on actors in a level when their level gets unloaded?

I need to clean up some things when a level gets unloaded. Is there a way for an actor to do something when its level gets unloaded?

This is something I’ve always been interested in too.

The only way I’ve been able to get around this is using GameEnding() in GameInfo. The trouble with this is that it won’t get called for clients. I guess for clients you could hack something around the local player controller Destroyed() event.

I’d be curious to know if you find something that I’ve missed.

In gameinfo the
function ResetLevel() Look at these inside that function.
PlayerController(C).ClientReset();
ShouldReset(A)

I just tested this and ResetLevel() doesn’t seem to get called when running “start someMapName”.

in utgame try this

state RoundOver extends MatchOver in that state is
function ResetLevel()

but it calls
Global.ResetLevel(); which inturn should call the one in gameinfo to reset whatever you need reset.

ok here are some comments i added long time ago when testing this stuff.

//only runs 1st round, not 2nd or more rounds
function StartMatch()

//only called when maps rounds are over
function RestartGame()

//runs at round end and not end game
function ResetLevel()

//things that reset calls to check if they need reset
function bool ShouldReset(Actor ActorToReset)

/** @return true if ActorToReset should have Reset() called on it while restarting the game, false if the GameInfo will manually reset it or if the actor does not need to be reset */
function bool ShouldReset(Actor ActorToReset)
{
return super.ShouldReset(ActorToReset);
}