Friday, October 25, 2013

How to create a custom HUD in UDK

UTGFxHudWrapper is the wrapper that deals with the Unreal Script side of the movie or movies ie checks if they are loaded, toggles visibility etc and stores the Class of the MinimapHUDClass in it's Default properties:

MinimapHUDClass=class'GFxMinimapHUD'

GFxMinimapHud on the other hand is the Unreal script that delves deeper into the Flash movie itself:

    TeamStatsMC = GetVariableObject("_root.teamStats");
    PlayerStatsMC = GetVariableObject("_root.playerStats");
    PlayerStatsMC.GotoAndStopI(3);
It also stores the reference to the actual Gfx movie you want to use in it's Default properties:

 MovieInfo=SwfMovie'UDKHud.udk_hud'
To create your own HUD simply extend these two classes and point to your own custom gfx movie

//CWHud .uc
class CWHud extends UTGFxHUDWrapper;
defaultproperties
{

MinimapHUDClass=class'CWMinimapHUD'
}
//CWMinimapHUD.uc
class CWMinimapHUD extends GFxMinimapHud;
defaultproperties
{
MovieInfo=SwfMovie'CWHud_UI.CWHud'
}
The HUD is instantiated inside the PlayerController Class:
//CWPlayerController .uc
CWPlayerController extends UTPlayerController; 

reliable client function ClientSetHUD(class<HUD> newHUDType)
{
if(myHUD != none)
{
myHUD.Destroy();
}
myHUD = spawn(class'CWHud', self);
}

No comments:

Post a Comment