I have been attempting to get a custom scaleform HUD with health tracking working over the past few days, and have had no luck so far. . . I've followed the http://noexp.wordpress.com/scaleform-hud-tutorial/ tutorials, and via various other finds, have fixed the script for use in the October version of UDK so that I get no compile errors or warnings, yet my HUD does not show up ingame, nor does the original HUD get removed. I can get the flash file to show up via kismet, so I know the flash file itself is fine, I just can't get it to work via script.
I'm just unsure of what I'm doing wrong with my script for it to not be working. Scripting is something I am not very good at, so I'm sure I've missed something, just unsure as to what. I've got 4 script files, as per the tutorial, all of which are in the MyMod/Classes folder at the moment. . .any ideas?
I'm just unsure of what I'm doing wrong with my script for it to not be working. Scripting is something I am not very good at, so I'm sure I've missed something, just unsure as to what. I've got 4 script files, as per the tutorial, all of which are in the MyMod/Classes folder at the moment. . .any ideas?
Code:
class SFGameInfo extends UTDeathmatch; DefaultProperties { //The class for your playerController (created later) PlayerControllerClass=class'MyMod.SFPlayerController' //The class for your GFx HUD Wrapper (created later) HUDType=class'MyMod.SFHUD' bUseClassicHUD=True //Required values bDelayedStart=false bRestartLevel=false Name="Default_SFGameInfo" }
Code:
class SFPlayerController extends UTPlayerController; DefaultProperties { bForceBehindView=false Name="Default__SFPlayerController" }
Code:
class SFHUD extends UTHUDBase; //Reference the actual SWF container (STGFxHUD created later) var SFGFxHUD HudMovie; //Called when this is destroyed singular event Destroyed() { if (HudMovie != none) { //Get rid of the memory usage of HudMovie HudMovie.Close(true); HudMovie = none; } } //Called after game loaded - initialise things simulated function PostBeginPlay() { super.PostBeginPlay(); //Create a STGFxHUD for HudMovie HudMovie = new class'SFGFxHUD'; //Set the timing mode to TM_Real - otherwide things get paused in menus HudMovie.SetTimingMode(TM_Real); //Call HudMovie's Initialise function HudMovie.Init(); } //Called every tick the HUD should be updated event PostRender() { HudMovie.TickHUD(); } DefaultProperties { }
Code:
class SFGFxHUD extends GFxMoviePlayer; //Create a Health Cache variable var float LastHealthpc; //Create variables to hold references to the Flash MovieClips and Text Fields that will be modified var GFxObject HealthMC, HealthBarMC; // Function to round a float value to an int function int roundNum(float NumIn) { local int iNum; local float fNum; fNum = NumIn; iNum = int( fNum ); fNum -= iNum; if ( fNum >= 0.5f ) return ( iNum + 1 ); else return iNum; } // Function to return a percentage from a value and a maximum function int GetPercentage( int Value, int MaxValue ) { return roundNum( ( float( Value ) / float( MaxValue ) ) * 100.0f); } //Called from STHUD'd PostBeginPlay() function Init( optional LocalPlayer LocPlay ) { Super.Init( LocPlay ); //Set the cahce value so that it will get updated on the first Tick LastHealthpc = -1337; //Load the references with pointers to the movieClips and text fields in the .swf HealthMC = GetVariableObject( "_root.healthbar_mc" ); HealthBarMC = GetVariableObject( "_root.healthbar_mc.bar_mc" ); } //Called every update Tick function TickHUD() { local PlayerController PC; local UTPawn UTP; PC = GetPC(); //We need to talk to the Pawn, so create a reference and check the Pawn exists UTP = UTPawn(PC.Pawn); if( UTP == None ) return; //If the cached value for Health percentage isn't equal to the current... if ( LastHealthpc != GetPercentage( UTP.Health, UTP.HealthMax ) ) { //...Make it so... LastHealthpc = GetPercentage( UTP.Health, UTP.HealthMax ); //...Update the bar's xscale (but don't let it go over 100)... HealthBarMC.SetFloat( "_xscale", (LastHealthpc > 100) ? 100.0f : LastHealthpc ); //...and update the text field } } DefaultProperties { MovieInfo=SwfMovie'FinalHUD.HUD.FinalHUD2' bDisplayWithHudOff=true bAllowInput=FALSE; bAllowFocus=FALSE; bAutoPlay=True; }
Comment