Game Crashes when Tank is Hit, AI Tanks Stop Firing too Soon

Since upgrading the mortar and adding code to stop AI Tanks and exit player tank on death, the game has started crashing when the tank is hit. Here’s the Unreal crash window:

There’s a reference to TankPlayerController.cpp(50), which I assume means line 50 in the cpp file. Here’s that code (it’s the aim towards crosshairs section):
/void ATankPlayerController::AimTowardsCrosshair()
/{
/ auto AimingComponent = GetPawn()->FindComponentByClass();
/ if (!ensure(AimingComponent)) { return; }
/
/ FVector HitLocation; //Out parameter
/ bool bGotHitLocation = GetSightRayHitLocation(HitLocation);
/ //UE_LOG(LogTemp, Warning, TEXT(“bGotHitLocation: %i”), bGotHitLocation)
/
/ if (bGotHitLocation) //has side effect, is going to line trace
/ {
/ AimingComponent->AimAt(HitLocation);
/ }
/}

Line 50 is the one that begins “auto”.

Additionally, when camera is swapped to first person, I can’t aim the tank. The turret and barrel stay pointed straight ahead of the tank.

Anyone else having similar issues?

Your line 50 appears to be missing the <Class> type part. I expect that does bork it.

auto AimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>();

https://github.com/UnrealCourse/04_BattleTank/blob/master/BattleTank/Source/BattleTank/Private/TankPlayerController.cpp

That should take care of that issue I would think.