I have a problem with accessing the Pawn class public variable from HUD class. Code is compiling without any error , but when I press play inside the editor UE is crashing.
First-chance exception at 0x00007FF9F1FAA65B (UE4Editor-VehicleGame-Win64-DebugGame.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x00000000000003A8.
void AVehicleHUD:: DrawHUD()
AVehicle* DummyBot = Cast<AVehicle>(UGameplayStatics::GetPlayerPawn(this, 0));
FString PowerLevelString = FString::FromInt(DummyBot->PowerLevel);
DrawText(PowerLevelString, FColor::Red, 50, 50, HUDFont);
Maybe someone has an idea what is wrong with it. I tried to find information but without any success.