Results 1 to 18 of 18
  1. #1

    Default Scaleform HUD Help

    So i have been trying to get a GFx HUD to work for two or three months now. I've watched all of the Scaleform tutorial videos a few times now and I am just not sure what I am doing wrong. The HUD shows up but it does not update to my current health or display the ammount of I have ammo.

    Code:
    class ZomHUD_Base extends UDKHUD;
    
    var ZomHUD HudMovie;
    
    //Handles death
    
    singular event Destroyed()
    {
    	if (HudMovie != none)
    	{
    		HudMovie.Close(true);
    		HudMovie = none;
    	}
    
    	super.Destroyed();
    
    }
    
    
    simulated function PostBeginPlay()
    {
    	super.PostBeginPlay();
    	CreateHUD();
    
    }
    
    
    
    function CreateHUD()
    {
            HudMovie = new class'ZomHUD';
    	HudMovie.SetTimingMode(TM_Real);
    	HudMovie.Init(class'Engine'.static.GetEngine().GamePlayers[HudMovie.LocalPlayerOwnerIndex]);
    	HudMovie.SetViewScaleMode(SM_ExactFit);
            HudMovie.SetAlignment(Align_TopLeft);
    }
    
    
    
    
     
    
    DefaultProperties
    {
    }
    Code:
    class ZomHUD extends GFxMoviePlayer;
    
    var float lastHealthPC;
    var float lastAmmoPC;
    
    
    var GFxObject HUDHealthBAR, HUDHealthBOX, HUDAmmoBOX;
    var GFxObject  ammo, clips;
    
    var GFXObject crosshair;
    
    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 int GetPercentage( int Value, int MaxValue ) 
    {
    	return roundNum( ( float( Value ) / float( MaxValue ) ) * 100.0f);
    
    }
    
    
    function Init( optional LocalPlayer LocPlay ) 
    {
    
     	Start();
    	Advance(0.f);
    
    	Super.Init( LocPlay );
    	
    	LastHealthpc = -1000;
    
    	HUDHealthBOX = GetVariableObject("_root.HUDHealthBOX");
    	HUDAmmoBOX = GetVariableObject("_root.HUDAmmoBOX");
    	HUDhealthBar = GetVariableObject("_root.HUDHealthBOX.HUDHealthBAR");
    	ammo = GetVariableObject("_root.HUDAmmoBOX.ammo");
    	clips = GetVariableObject("_root.HUDAmmoBOX.clips");
    	
    	
    }
    
    
    function TickHUD()
    {
    	local PlayerController PC;
    	local Zompawn ZP;
    
            PC = GetPC();
    
            ZP = ZomPawn(PC.Pawn);
    	       
    
            if (ZP == None || ZP.Weapon == None)
    		{
    		return;
    		}
    		if (lastHealthPC != GetPercentage(ZP.Health, ZP.HealthMax))
    			{
    			lastHealthPC = GetPercentage(ZP.Health, ZP.HealthMax);
    			HUDHealthBAR.SetFloat("_xscale", (lastHealthPC > 100) ? 100.0f : lastHealthPC);
    			}
    		if (lastAmmoPC != GetPercentage(ZomWeapon(ZP.Weapon).MagAmmo, ZomWeapon(ZP.Weapon).MaxMagAmmo)) 
    		{
    			lastAmmoPC = GetPercentage(ZomWeapon(ZP.Weapon).MagAmmo, ZomWeapon(ZP.Weapon).MaxMagAmmo);
    
    		}
    		ammo.SetString("text", (ZomWeapon(ZP.Weapon).MagAmmo)$" / "$(ZomWeapon(ZP.Weapon).MaxMagAmmo)$"");
    
    
            clips.SetString("text", (ZomWeapon(ZP.Weapon).MaxAmmoCount)$"");
    
    }
    
    DefaultProperties
    {
    	bIgnoreMouseInput = false
    	bAutoPlay=True
    	bDisplayWithHudOff=false
    	MovieInfo=SwfMovie'ZomHUD.CleanHUD'
    	
    }
    I probably made a stupid mistake somewhere. Any help would be nice. Thank you.
    Last edited by brain_rot; 04-03-2012 at 09:34 PM.

  2. #2

    Default

    You forgot to have your HUD wrapper execute TickHud().

    Code:
    event PostRender()
    {	
    	super.PostRender();
    
    	if (HudMovie != none)
    	{
    		HudMovie.TickHud(0);
    	}
    }
    Also, change your TickHud() function to this:

    Code:
    function TickHud(float DeltaTime)

  3. #3

    Default

    Thank you for the quick reply. I changed the code but nothing seems to have changed. Any other ideas?

    Code:
    class ZomHUD_Base extends UDKHUD;
    
    var ZomHUD HudMovie;
    
    //Handles death
    
    singular event Destroyed()
    {
    	if (HudMovie != none)
    	{
    		HudMovie.Close(true);
    		HudMovie = none;
    	}
    
    	super.Destroyed();
    
    }
    
    
    simulated function PostBeginPlay()
    {
    	super.PostBeginPlay();
    	CreateHUD();
    
    }
    
    
    
    function CreateHUD()
    {
            HudMovie = new class'ZomHUD';
    	HudMovie.SetTimingMode(TM_Real);
    	HudMovie.Init(class'Engine'.static.GetEngine().GamePlayers[HudMovie.LocalPlayerOwnerIndex]);
    	HudMovie.SetViewScaleMode(SM_ExactFit);
            HudMovie.SetAlignment(Align_TopLeft);
    }
    
    event  PostRender()
    {
          super.PostRender();
          if(HudMovie != none)
       {
           HudMovie.TickHUD(0);
       }
    }
    
    
    
    DefaultProperties
    {
    }
    Code:
    class ZomHUD extends GFxMoviePlayer;
    
    var float lastHealthPC;
    var float lastAmmoPC;
    
    
    var GFxObject HUDHealthBAR, HUDHealthBOX, HUDAmmoBOX;
    var GFxObject  ammo, clips;
    
    var GFXObject crosshair;
    
    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 int GetPercentage( int Value, int MaxValue ) 
    {
    	return roundNum( ( float( Value ) / float( MaxValue ) ) * 100.0f);
    
    }
    
    
    function Init( optional LocalPlayer LocPlay ) 
    {
    
     	Start();
    	Advance(0.f);
    
    	Super.Init( LocPlay );
    	
    	LastHealthpc = -1000;
    
    	HUDHealthBOX = GetVariableObject("_root.HUDHealthBOX");
    	HUDAmmoBOX = GetVariableObject("_root.HUDAmmoBOX");
    	HUDhealthBar = GetVariableObject("_root.HUDHealthBOX.HUDHealthBAR");
    	ammo = GetVariableObject("_root.HUDAmmoBOX.ammo");
    	clips = GetVariableObject("_root.HUDAmmoBOX.clips");
    	
    	
    }
    
    
    function TickHUD(float DeltaTime)
    {
    	local PlayerController PC;
    	local Zompawn ZP;
    
            PC = GetPC();
    
            ZP = ZomPawn(PC.Pawn);
    	       
    
            if (ZP == None || ZP.Weapon == None)
    		{
    		return;
    		}
    		if (lastHealthPC != GetPercentage(ZP.Health, ZP.HealthMax))
    			{
    			lastHealthPC = GetPercentage(ZP.Health, ZP.HealthMax);
    			HUDHealthBAR.SetFloat("_xscale", (lastHealthPC > 100) ? 100.0f : lastHealthPC);
    			}
    		if (lastAmmoPC != GetPercentage(ZomWeapon(ZP.Weapon).MagAmmo, ZomWeapon(ZP.Weapon).MaxMagAmmo)) 
    		{
    			lastAmmoPC = GetPercentage(ZomWeapon(ZP.Weapon).MagAmmo, ZomWeapon(ZP.Weapon).MaxMagAmmo);
    
    		}
    		ammo.SetString("text", (ZomWeapon(ZP.Weapon).MagAmmo)$" / "$(ZomWeapon(ZP.Weapon).MaxMagAmmo)$"");
    
    
            clips.SetString("text", (ZomWeapon(ZP.Weapon).MaxAmmoCount)$"");
    
    }
    
    DefaultProperties
    {
    	bIgnoreMouseInput = false
    	bAutoPlay=True
    	bDisplayWithHudOff=false
    	MovieInfo=SwfMovie'ZomHUD.CleanHUD'
    	
    }
    Is there anything at all in action script I need for a HUD to work?

  4. #4

    Default

    Not sure what could be wrong then. You'll need to check the log for error messages. Try adding some `log messages in your functions to see if any of them are actually firing too. I'd also recommend moving the Super.Init( LocPlay); line above Start() and Advance(0.f).

  5. #5

    Default

    So I checked my log and it was very lengthy.

    A summary

    Code:
    [0030.20] ScriptWarning: Accessed None 'HUDHealthBAR'
    ZomHUD Transient.ZomHUD_0
    Function TerminalConstant.ZomHUD:TickHUD:01F2
    
    [0030.20] ScriptWarning: Accessed None 'Ammo'
    ZomHUD Transient.ZomHUD_0
    Function TerminalConstant.ZomHUD:TickHUD:03BE
    
    [0030.20] ScriptWarning: Accessed None 'Clips'
    ZomHUD Transient.ZomHUD_0
    Function TerminalConstant.ZomHUD:TickHUD:04A5
    This went on for pages.
    Any Idea what it means?
    Thanks for the Help

  6. #6

    Default

    Accessed None means your assets don't exist when you try to do something with them. Which means that these references:

    Code:
    HUDHealthBOX = GetVariableObject("_root.HUDHealthBOX");
    	HUDAmmoBOX = GetVariableObject("_root.HUDAmmoBOX");
    	HUDhealthBar = GetVariableObject("_root.HUDHealthBOX.HUDHealthBAR");
    	ammo = GetVariableObject("_root.HUDAmmoBOX.ammo");
    	clips = GetVariableObject("_root.HUDAmmoBOX.clips");
    are pointing to nothing. You will need to figure out why. Incorrect instance names? Don't exist on frame 1? What file format are you using? AS2 or AS3? If AS2, "_root" is correct, but if AS3, instead you must use "root".

    I did notice that your names don't match:

    HUDhealthBar vs. HUDHealthBAR

    Is UnrealScript case sensitive? I can't recall.
    Last edited by Matt Doyle; 04-04-2012 at 02:11 PM.

  7. #7

    Default

    I am using AS2. Well that is odd. I'll check my .fla

  8. #8

    Default

    Alright, after looking at my .fla, I noticed something. My instance name is different from my instant of. Does this affect anything? I have tried removing HUD from the beginning of the references and I still get the same errors in my log.


  9. #9

    Default

    It loooks like your problem is that HUDHealthBar is not a movie clip, but just a Bitmap. You can't give a Bitmap on the stage an instance name. 'Instance of:' is not the same thing as instance name. Convert HUDHealthBar to a movie clip, then give it an instance name.

  10. #10

    Default

    I converted the bitmaps to movie clips and changed the references in my code but I still get the same error. Would it be alright if I pm-ed you my .fla? I understand if you are busy. Thanks for the help.

  11. #11

    Default

    Sure. Go ahead.

  12. #12

    Default

    Just sent it.

  13. #13

    Default

    You'll have to resave it as CS4 or CS5, as I don't have CS5.5 here.

  14. #14

    Default

    Just sent it.

  15. #15

    Default

    Ok. It sould be is CS4 now. Thanks for being patient.

  16. #16

    Default

    So, this is your path:

    "_root.HealthBOX.HealthBAR"

    And...

    "_root.AmmoBOX.AmmoBOX.Ammo"

  17. #17

    Default

    Thank you so much for your help. My health bar is now working. I am still having trouble with my Ammo showing up properly. Do the text fields need something special in the reference? I have two text fields in the AmmoBOX movie clip. I have the text field set to dynamic.

  18. #18
    The Sacrifice
    Join Date
    Jul 2010
    Location
    Holly Springs, MS
    Posts
    414

    Default

    I have been reading this and it has helped me so much to develop a working Gfx Hud. Thanks guys!
    Fortis Rex Rise Of The King, A Medieval Army-Commanding RPG: http://forums.epicgames.com/threads/...7#post29971877


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.