My cast<> too APlayerController is failing. Need help.
Hey, i'm trying to get access to my HUD from my FPS character. Currently i'm trying this out
But this does not work for me as i'm always getting the error. From what i read this should work. Anyone have any idea why it is not working for me? I currently have no self made player controller class, is one required to get the HUD?
Have you declared the MyHUD variable? E.g. have you tried the following: AHUD* MyHUD = Cast(MyPC->GetHUD());
You could also check if your PC or HUD is valid:
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Green, MyPC->GetName()); GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Green, MyHUD->GetName());
What is your error message?
when do you call that method? Can you please check if the Controller isn't NULL at that point before, so we know it's a matter of the cast. (as it might as well just be NULL already before and you try to cast -> NULL again) Maybe you need to call the method after the pawn is possessed by a controller ( I guess you call it really early, like in the constructor?)
Follow this question
Once you sign in you will be able to subscribe for any updates here