Announcement

Collapse
No announcement yet.

Scaleform HUD not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Scaleform HUD not working

    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?

    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;
    }

    #2
    I can't support the user created HUD tutorial you've followed, but have you watched video 2 - setting up config files, etc.?

    Could be a problem there.

    Also, I cannot verify if his tutorial works in later builds of UDK.

    Comment


      #3
      Originally posted by Airrow View Post
      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?

      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;
      }
      Ok there are a couple things i'm noticing that you're missing from the code that he provided... dunno if these produce errors or not but....

      his code in STGFxHUD
      Code:
      //Called from STHUD'd PostBeginPlay()
      function Init(PlayerController PC) {
       //Start and load the SWF Movie
       Start();
       Advance(0.f);
      yours
      Code:
      //Called from STHUD'd PostBeginPlay()
      function Init( optional LocalPlayer LocPlay ) 
      {
      Super.Init( LocPlay );
      That part is pretty different, might be causing issues, another thing i noticed was up in STHUD

      His code:
      Code:
       //Create a STGFxHUD for HudMovie
       HudMovie = new class'STGFxHUD';
       //Set the HudMovie's PlayerOwner
       HudMovie.PlayerOwner = PlayerOwner;
       //Set the timing mode to TM_Real - otherwide things get paused in menus
       HudMovie.SetTimingMode(TM_Real);
       //Call HudMovie's Initialise function
       HudMovie.Init(HudMovie.PlayerOwner);
      yours
      Code:
      //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();
      Looks like you're missing the HudMovie.PlayerOwner = PlayerOwner; code.

      From my skim over it just looks like you're missing some code in certain areas, a friend of mine just did this tutorial (or one that was almost exactly the same) and the only thing that needed to be changed was all references of getpc changed to getpercentage which i see that you've done.

      So it might be that you're missing some lines of code. If you were looking at the video it was hard to read so just in case you were goin off of that here's the link to his code (in case you didn't notice it)

      http://noexp.wordpress.com/copypasta...-actionscript/

      ***EDIT*** One way you could do it is go into the link i gave you and copy and paste it, changing the getpc's to getpercentage, and then since it looked like you were using SFHUD instead of STHUD just change all the instances of ST to SF

      Comment


        #4
        Have you added anything else so you can verify that it is actually using your code at all?

        Comment

        Working...
        X