Accessing Pawn Class Public Variable C++

I would say that in this case your variable ‘DummyBot’ is probably NULL. You need to check the result of your cast before you use the variable. So:



void AVehicleHUD:: DrawHUD()
{
   Super:: DrawHUD(); 
   AVehicle* DummyBot = Cast<AVehicle>(UGameplayStatics::GetPlayerPawn(this, 0)); 
   if (DummyBot) {
      FString PowerLevelString = FString::FromInt(DummyBot->PowerLevel);
      DrawText(PowerLevelString, FColor::Red, 50, 50, HUDFont);
   }
}