Time for action – Using the HUD
We're going to use our HUD to display some useful information, such as our weapon level and the number of enemies we have left to kill. First we need to create our own HUD class.
Create a new file in our
Development/Src/AwesomeGame/Classes
folder calledAwesomeHUD.uc
. Type the following code into it:class AwesomeHUD extends UTGFxHUDWrapper; simulated function PostBeginPlay() { super.PostBeginPlay(); `log("AwesomeHUD spawned!"); } defaultproperties { }
Now we're going to replace the default HUD with our own class. In our
AwesomePlayerController
, add the following function:reliable client function ClientSetHUD(class<HUD> newHUDType) { if(myHUD != none) myHUD.Destroy(); myHUD = spawn(class'AwesomeHUD', self); }
Now our HUD will be the only type that can be spawned for our
AwesomePlayerController
.Compile the code and run the game. Nothing looks different, but close the game and check the log:
[0004.37] ScriptLog: AwesomeHUD spawned...