The HUD is provisioned in the file MyGame.UC and the example HUD Epic Games includes is 'UTGame.UTHUD', which has a dynamic compass, a health bar, and an ammo count, and a crosshair for aiming. These can be either modified or completely replaced, and there are various ways to make a working HUD, so what we will do here is just assume you want to remove the existing HUD and are comfortable adding your own content once you know what goes where. Most HUDs are now built upon Scaleform, and to get started with that, in respect of UI, it could be a good idea to look at http://udn.epicgames.com/Three/ScaleformWorkflow.html
. An example of how the HUD and camera relate is at http://forums.epicgames.com/showthread.php?t=721726. Chapter 10, The Way of the Flash UI also discusses the basics of working with Scaleform.
In this section we are not going to cover comprehensive HUD provisioning, only some simple configuration tricks that are handy, that will expose users to the bare bones of this extensive body of content.
The new default map types begin with no GameType and therefore no HUD. Others begin with UTGame (which was the default up till the July 2011 version and can still be set in View | WorldProperties | Game Type). In any scene it is worthwhile to know that to show no HUD at all we can use the Toggle HUD action or Toggle Cinematic Mode action in Kismet with Hide HUD ticked in its properties.
Using UTGame, you may not only want to hide not just the HUD but the Unreal Tournament legacy weapon from the view too. After all, there's no point seeing a laser rifle bobbing in front of you when your game is a caveman simulator for instance. Neither of the HUD toggles will hide the UTGame weapon, but in this case you can also add a Player Spawned event in Kismet (not a Level Loaded since the player must spawn first) and connect to it a New Action | Pawn | Give Inventory action. Set the Give Inventory action so it has a new entry [ ] with None set and tick on the property Clear Existing.
class MyGame extends UDKGame config(MyGame); DefaultProperties { HUDType=class'MyGame.MyHUD' // bUseClassicHUD=true // This code sample cannot use the line above as it does not extend from UTGame but from UDKGame... }
class MyHUD extends UDKHUD;
event PostRender()
{
DrawGameHud
}
//PostRender occurs after all the content of the game is sorted out.
function DrawGameHud(){
if ( !PlayerOwner.IsDead() && !PlayerOwner.IsInState('Spectating'))
{
// Set the position on the screen...
Canvas.SetPos(Canvas.ClipX/2,Canvas.ClipY/2);
// Set the text colour to white...
Canvas.SetDrawColor( 255, 255, 255, 255 );
// Sets a medium font to use...
Canvas.Font = class 'Engine'.static.GetMediumFont();
///You can also use GetSmallFont or GetHugeFont
// Sets the text to display...
Canvas.DrawText( "This HUD is basic!" );
}
}DefaultProperties{
}
DrawText
instruction if you don't want it there. Instead, use Draw Text actions in Kismet. This example is just a starter. If you want to adjust text colour, remember that the 255,255,255,255 first three numbers are RGB values and the fourth is Alpha, for transparency.C:UDK~DevelopmentSrcUTGameClassesGFxMinimapHud.UC
and then comment out: //Minimap.Update(CurZoomf);
By default the hotkeys F2 (map) and F3 (minimap) are for in game map toggling.
If you like the minimap but want to make it smaller, leave the previous line as it was, and instead press Ctrl + F and search for 85; which happens to be the scale value for the compass and should expose the lines:
Minimap.SetFloat("_xscale", 85); Minimap.SetFloat("_yscale", 85);
//
, so you don't have to remember the defaults, then add in this replacement underneath:Minimap.SetFloat("_xscale", 25); Minimap.SetFloat("_yscale", 25);
C:UDK~DevelopmentSrcUTGameClassesGFxMinimapHud.UC
and in the DefaultProperties
put in false
instead of true
in the line: bDrawWeaponCrosshairs=true
.ToggleCrosshair(bool bToggle)
you can always add a hotkey to the DefaultInput.INI file, as we discussed in earlier recipes, such as: Binding a keyboard shortcut to a player action.C:UDK~UDKGameFlashUDKHudUDK_minimaput3_minimap_compass.PNG
.3.128.171.246