.
…
But in my HUD it references a variable
from the player controller, which is
set on begin play, to get the local
player.
Destroyed actors are put on the Pending Kill list to be picked up by Garbage Collection after which the memory they resided it can be freed. During this time access to this actor is blocked - if you do try to access it (what the HUD attempts here) - you get an unfriendly warning message…
One solution is to have the HUD check whether the object isValid:
But that’s band-aid solution only.
But in my HUD it references a variable
from the player controller, which is
set on begin play, to get the local
player.
Ideally, when you respawn the player, ensure the variable is referencing the newly spawned actor; have your respawn function access the Player Controller and set the offending reference’s value.