Checking if an actor is valid during streaming level unloading.


I have an actor that may be one of several controlled by the player. It has a UFUNCTION which is a BlueprintImplementableEvent. The function is being called from the player controller from a function bound to an axis input (continuously).

When the streaming level is unloaded and the player controller is still sending commands to this pawn the game will crash unless I check the actor using an IsValidLowLevel or IsValidLowLevelFast. I can’t simply check IsPendingKill or check if it is null or not. While these checks will work they unfortunately spam the output log with errors or warnings.

I know I can simply remove the playercontroller references to any pawn in the level but there are other things going on in the level that may possible cause a crash for this same reason.

I was wondering if there was a proper way to check for an actors validity as the streaming level it is in is being unloaded. Perhaps this has something to do with the function being a BlueprintImplementableEvent because it will only crash while inside that function because it has no reference to itself to do things (it’s like the function still exists but the actor doesn’t).

Is there a proper way to avoid this crash aside from having everything that exists in the level stopping before unloading the level. I know it’s possible to do it all cleanly but I was hoping there was a path that already existed in UE4 to unload a streaming level safely.

Thank you.