Unable to change the HUD class in the runtime using blueprint

Hi ,

I tried the following code in GameMode blueprint , to change the HUD class in runtime based on certain conditions. But for some reason it is not working.

That variable is just contains class identifier for HUD class that should be used in HUD initiation and C++ as well as blueprint does not support property change event on primitive variable (but there one event that is called when you change something in details tab in editor). So HUD need to be reinitialized, destroy old HUD or just hide it somewhere and spawn and set new one.

Problem is looks on API reference all varables and functions that allows to do that are accessible via blueprint, you would need to do that in C++:

Good workaround here would be holding functionality of both HUDs in single class and swap draw rutines between then. If you not afraid of C++ there easier work around, try exposing that function in first link to blueprint, to do that create PlayerController class in C++ and in .h file add this to class decleration:

UFUNCTION(BlueprintCallable, Category="HUD")
void SetHUD(TSubclassOf<class AHUD> NewHUDClass);

And in .cpp file add this after constructor (at the end of file):

void ASomePlayerController::SetHUD(TSubclassOf<AHUD> NewHUDClass) {
      ClientSetHUD(NewHUDClass);
}

replace ASomePlayerController with your class name, hen make a blueprint based of that class and you should able to call “Set HUD” in HUD. Remeber that i did this just in my head and that function has to do something with replication which i didnt play with, so im not 100 sure if this will work but it a worth a try .

also if you got some compile errors try changing “class AHUD” to “AHUD”