Announcement

Collapse
No announcement yet.

Scaleform, HUD don't appear

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

  • replied
    Hello MissLarson,

    I'm assuming your are looking at this tutorial http://noexp.wordpress.com/copypasta...-actionscript/. It is a little outdated and a few things don't work anymore(atleast for me they didnt). I am new to scaleform aswell (which i am loving btw... just a lil different and unique).

    The code below works just fine for me (with the May 2011 UDK Beta). I did not add/remove/extend any functionality or anything, just got it working like the tutorial. I have slightly different classname / symbol names in flash... but if you change it to your values all should work

    rpgGameInfo.uc
    Code:
    class rpgGameInfo extends UTDeathMatch;
    
    DefaultProperties
    {
    	Acronym="RPG"
    	HUDType= class 'RPG.rpgHUD'
    	PlayerControllerClass=class 'RPG.rpgPlayerController'
    	bUseClassicHUD=true
    	bDelayedStart=false
    	bRestartLevel=false
    	name="Default__rpgGameInfo"
    	
    }
    rpgHUD.uc
    Code:
    class rpgHUD extends UTHUDBase;
    
    var rpgGFXhud HudMovie;
    
    singular event Destroyed() {
     if (HudMovie != none) {
     //Get rid of the memory usage of HudMovie
     HudMovie.Close(true);
     HudMovie = none;
     }
    
     super.Destroyed();
    }
    
    //Called after game loaded - initialise things
    simulated function PostBeginPlay() {
     super.PostBeginPlay();
    
     //Create a STGFxHUD for HudMovie
     HudMovie = new class'rpgGFXhud';
     //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.Owner);
    }
    
    //Called every tick the HUD should be updated
    event PostRender() {
     HudMovie.TickHUD();
    }
    
    DefaultProperties
    {
    }
    rpgGFXhud.uc
    Code:
    class rpgGFXhud 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;
    var GFxObject HealthTF;
    var localPlayer Owner;
    
    
    //  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 getpcc(int val, int max) {
     return roundNum((float(val) / float(max)) * 100.0f);
    }
    
    //Called from STHUD'd PostBeginPlay()
    function Init(optional LocalPlayer LocPlay) {
     //Start and load the SWF Movie
     Start();
     Advance(0.f);
    
     //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");
     HealthTF = GetVariableObject("_root.HealthBar_MC.Health_TXT");
    }
    
    //Called every update Tick
    function TickHUD() {
     local UTPawn UTP;
     local PlayerController PC;
    
     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 != getpcc(UTP.Health, UTP.HealthMax)) {
     //...Make it so...
     LastHealthpc = getpcc(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
     HealthTF.SetString("text", round(LastHealthpc)$"%");
     }
    }
    
    DefaultProperties
    {
     //this is the HUD. If the HUD is off, then this should be off
     bDisplayWithHudOff=false
     //The path to the swf asset we will create later
     MovieInfo=SwfMovie'rpgHUD.HealthBar'
     //Just put it in...
     bEnableGammaCorrection = false
    }
    rpgPlayerController.uc
    Code:
    class rpgPlayerController extends UTPlayerController;
    
    DefaultProperties
    {
    	bForceBehindView=False
    	name="Default__rpgPlayerController"
    }
    Best of Luck!

    P.S. I noticed in your code you commented out a few of the lines of code. As a tip don't just comment out where you are getting errors :-P. 1. There is usually a reason why it was there (and you can recode it differently to do the same thing) and 2. 9/10 it will cause more errors because your program will end up breaking later on because of it.

    Leave a comment:


  • replied
    That didn't work either. But we have decided to skip the HUD in our game since it was so hard to get it to work and our time for our assignment is starting to run out. But I really appreciated your help

    Leave a comment:


  • replied
    Originally posted by misslarson View Post
    Yes, that have I done. I also have these lines in GameInfo:
    HUDType=class 'MyHUD'
    bUseClassicHUD=true;
    HUDType=class'LastStand.LSHUD';

    Development/Src/LastStand/LSHUD.uc results in the path above.


    Put your gameinfofile in a folder inside Src and do like me

    Leave a comment:


  • replied
    The editor doesn't always give the same result as starting up the game from the standalone game. try the following: create a shortcut to e.g

    C:\UDK\UDK-2011-03\Binaries\Win64\UDK.exe

    then modify the target as this:

    C:\UDK\UDK-2011-03\Binaries\Win64\UDK.exe MapName?game=Classes.Gameinfofile -vadebug -nomoviestartup -resx=1366 -resy=768 -log

    where Classes.Gameinfofile is the path (now, the original path) to your gameinfo, eg I have the GameInfofile LastStand laying under the LastStand folder, hence i use LastStand.LastStand.

    Start up the shortcut and see if you see results

    Leave a comment:


  • replied
    Yes, that have I done. I also have these lines in GameInfo:
    HUDType=class 'MyHUD'
    bUseClassicHUD=true;

    Leave a comment:


  • replied
    Have you made a GameInfo file extending UTDeathmatch and set it in the wolrd properties of the level you are running?

    Leave a comment:


  • replied
    Ah, now I found it. I pasted it in the script but unfornatley I still have the same problem

    Leave a comment:


  • replied
    Originally posted by misslarson View Post
    ..\..\UDKGame\Flash\OpenDoor\HUD\HUD.swf that is the search path, so this(OpenDoor.HUD.HUD) should be right but it doesn't work
    That is NOT the searchpath you are looking for.
    The path YOU are describing is the path to the swf file BEFORE you imported your swf file to an UDK package in the content browser. So once again, forget about where your swf file is residing in the folder hierarchy

    The path you need is the path you get when you open up udk Editor, go to the View -> Browser Windows ->content browser and then search for the swf file you've imported into the content browser. Rightclick that icon and select "Copy Full Name To Clipboard" and the result should look something like this:

    SwfMovie'HUD.DroidCutscene'

    Leave a comment:


  • replied
    ..\..\UDKGame\Flash\OpenDoor\HUD\HUD.swf that is the search path, so this(OpenDoor.HUD.HUD) should be right but it doesn't work

    Leave a comment:


  • replied
    Originally posted by misslarson View Post
    Then I'm back to the same problem again... My swf file lies in the package OpenDoor (the same as my .udk file) under the group HUD so the search way should be like this: MovieInfo=SwfMovie'Flash.OpenDoor.HUD.HUD' right? But it doesn't work...

    This is really frustrating...
    if you rightclick the swf file in the content browser (or any file for that matter), and select copy paths, a string containing the correct search path will be copied to your clipboard

    Leave a comment:


  • replied
    Then I'm back to the same problem again... My swf file lies in the package OpenDoor (the same as my .udk file) under the group HUD so the search way should be like this: MovieInfo=SwfMovie'Flash.OpenDoor.HUD.HUD' right? But it doesn't work...

    This is really frustrating...

    Leave a comment:


  • replied
    You're right Charleon. He's not actually using the HUD wrapper to instantiate the HUD, and thus no updates are occuring, since he's creating it in Kismet.

    Leave a comment:


  • replied
    Originally posted by misslarson View Post
    Thank you, I now got it to work
    But my problem now are that the health percent text don't change when the player get hurt... Does anyone know why? You can see the code in my first post, it's in MGGFxHUD. I think that I have done everything right in flash, in the different movieclips properties are their name for example healthbar_mc and when I export them for actionscript in the libary I name them without the mc, is that right?

    And I don't know if that matters, but I'm loading the HUD in Kismet instead for the script now.
    If you're not instantiating them from the LIbrary, their Librarynames should not matter, what matters is what the instance names are in the scenes. Also: If you open the flash in Kismet (Correct me if i'm wrong here Matt), You aren't actually wrapping your flashfile with the class you made for it, you're basically just loading the swf file without ANY attachments, code or whatever. you COULD do the update of the HUD throgh Kismet, but everything would turn spaghetti pretty fast. My recommendation is that you start the HUD element with code.

    Leave a comment:


  • replied
    Thank you, I now got it to work
    But my problem now are that the health percent text don't change when the player get hurt... Does anyone know why? You can see the code in my first post, it's in MGGFxHUD. I think that I have done everything right in flash, in the different movieclips properties are their name for example healthbar_mc and when I export them for actionscript in the libary I name them without the mc, is that right?

    And I don't know if that matters, but I'm loading the HUD in Kismet instead for the script now.

    Leave a comment:


  • replied
    What Mr Doyle says is that:
    In order for you to actually receive a path to the Swf file, it has to be IMPORTED into UDK, just puttingit into the flash directory is not enough, you have to go into the Content Browser and select Import and specify a package and identifyer name for it to be referenced by. In this exampe you would need to import it into the package MyGame with the name Hud

    Leave a comment:

Working...
X