Hard to find Hard crash?

My editor will hard crash if I attempt to open the PlayerController_BP, however the game runs just fine…I used the debugger and it seems to be getting stuck on AimTowardsCrosshair stating that AimingComponent is a nullptr. The game plays fine so far (I can aim and even fire at this point) so I’m not sure whats going on. I’ve compared code to the tankplayercontroller.cpp on bens github and I don’t see any difference in the code:

void ATankPlayerController::AimTowardsCrosshair() {

auto AimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();
if (!ensure(AimingComponent)) { return; }

FVector HitLocation; // Out parameter
if (GetSightRayHitLocation(HitLocation)) // Has "side-effect", is going to line trace
{
	AimingComponent->AimAt(HitLocation);
}	

}
and here is the crash log:

Access violation - code c0000005 (first/second chance not available)

UE4Editor_BattleTank_2928!ATankPlayerController::AimTowardsCrosshair() [d:\gitrepo\battletanks\battletank\source\battletank\tankplayercontroller.cpp:24]
UE4Editor_Engine!APlayerController::TickActor() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\playercontroller.cpp:3951]
UE4Editor_Engine!FActorTickFunction::ExecuteTick() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\actor.cpp:111]
UE4Editor_Engine!FTickFunctionTask::DoTask() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\ticktaskmanager.cpp:262]
UE4Editor_Engine!TGraphTask::ExecuteTask() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\core\public\async\taskgraphinterfaces.h:999]
UE4Editor_Core!FNamedTaskThread::ProcessTasksNamedThread() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\core\private\async\taskgraph.cpp:932]
UE4Editor_Core!FNamedTaskThread::ProcessTasksUntilQuit() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\core\private\async\taskgraph.cpp:679]
UE4Editor_Core!FTaskGraphImplementation::WaitUntilTasksComplete() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\core\private\async\taskgraph.cpp:1776]
UE4Editor_Engine!FTickTaskSequencer::ReleaseTickGroup() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\ticktaskmanager.cpp:530]
UE4Editor_Engine!FTickTaskManager::RunTickGroup() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\ticktaskmanager.cpp:1432]
UE4Editor_Engine!UWorld::RunTickGroup() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\leveltick.cpp:704]
UE4Editor_Engine!UWorld::Tick() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\leveltick.cpp:1197]
UE4Editor_Kismet!FSCSEditorViewportClient::Tick() [d:\build++ue4+release-4.12+compile\sync\engine\source\editor\kismet\private\scseditorviewportclient.cpp:201]
UE4Editor_UnrealEd!UEditorEngine::Tick() [d:\build++ue4+release-4.12+compile\sync\engine\source\editor\unrealed\private\editorengine.cpp:1409]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() [d:\build++ue4+release-4.12+compile\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:368]
UE4Editor!FEngineLoop::Tick() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2775]
UE4Editor!GuardedMain() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\launch.cpp:148]
UE4Editor!GuardedMainWrapper() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() [d:\build++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:200]
UE4Editor!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264]
kernel32
ntdll

Any idea what could be causing my hard crash?

Sorry if this is addressed in later videos!

I assume it’s this line GetPawn()->FindComponentByClass<UTankAimingComponent>(); so check that GetPawn() doesn’t return a nullptr first.

1 Like

That was totally it, I added if (!ensure(GetPawn())) { return; } right before and it fixed it. Thanks for the assist!

same issue, same solution.
thanks for your help

I had the same problem!! Same solution! Thanks!

Privacy & Terms