(Line 31 is AGroundersCharacter* Char = GetPawn<AGroundersCharacter>();, but assigning a variable without using it shouldn’t crash it, right? I do check before using)
But it almost doesn’t matter, I tried it with
int32 x = 15;
UE_LOG(LogTemp, Warning, TEXT("%i"), x);
and that doesn’t work either, the error line was int32 x = 15;
My guess is that the entire AGroundersPlayerState is null and the stack trace is lying. I would take a backup of the project, then remove all references to GetIsGrounder() and see what happens. Then I would re-add every reference 1 by 1 until it crashes again to see which specific call is the issue.
Probably something else is trying to access that PlayerState after the game has already invalidated it. I’d run it in debugger, and get a good call stack on it. Whatever is calling that shouldn’t be calling it if the game is terminating.
Found it. I’m calling it in LogOut on the gamemode. It’s understanable but I was under the impression that the player’s objects are destroyed after that code. Guess I’ll have to find something else to run that. (Super::LogOut is run at the end of my override btw)
I’ve changed the code so that if it is the server disconnecting (clients disconnecting works fine) it doesn’t run the code and instead disconnects all clients first. Many thanks