Crash by playing in GameMode with PlayerController (C++)

If you have BSP on your level, then the cause may be in 28 and 29 line of code of your PlayerControll.cpp file.

In line 28 you assume, that whenever you hit anything, it’s already an actor, which is wrong. BSP for example isn’t a an actor (thus hit.GetActor() returns nullptr), yet it could be detected by your linetrace. I’m not sure if there are any other objects like BSP that would block linetrace despite the fact they aren’t actual actors.

Anyway, to fix this you could replace your condition in 28th line to this:

if (PC_World->LineTraceSingleByChannel(*hit, cm->GetCameraLocation(), *c_loc + *c_dir * 1000, ECC_Pawn) && hit.GetActor())