Announcement

Collapse
No announcement yet.

Scaleform, HUD don't appear

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

    Scaleform, HUD don't appear

    I've been following the scaleform tutorial at noexperience, and at least I have succeeding in not having any errors. But the problem I have are that my code don't find the swf movie... I've checked around in the forum and on the internet but haven’t found a solution.
    Anyone that knows what I've done wrong?

    This is the code in the class MGGFxHUD extends GFxMoviePlayer
    Code:
    //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;
    
    //  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 getPcnt(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;
    
        //We need to talk to the Pawn, so create a reference and check the Pawn exists
    UTP = UTPawn( GetPC().Pawn );
    if ( UTP == None ) 
    return;
    
        
        //If the cached value for Health percentage isn't equal to the current...
        if (LastHealthpc != getPcnt(GetPC().Pawn.Health, GetPC().Pawn.HealthMax)) 
        {
            //...Make it so...
            LastHealthpc = getPcnt(GetPC().Pawn.Health, GetPC().Pawn.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'MyGame.HUD'
     //Just put it in...
     //bGammaCorrection = false
    }
    And in the class MyHUD extends UTHUDBase;
    Code:
    //Reference the actual SWF container (STGFxHUD created later)
    var MGGFxHUD 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;
     }
    
     Destroy();
    }
    
    //Called after game loaded - initialise things
    simulated function PostBeginPlay() {
     super.PostBeginPlay();
    
     //Create a STGFxHUD for HudMovie
     HudMovie = new class'MGGFxHUD';
     //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();
    }
    
    //Called every tick the HUD should be updated
    event PostRender() {
     HudMovie.TickHUD();
    }
    
    DefaultProperties
    {
    }
    Thanks in advance

    #2
    If it's the .swf it's asking for, tha tmeans that all other associations are right.

    MovieInfo=SwfMovie'MyGame.HUD'

    Are you sure that the Swfmovie for the HUD is indeed placed under the MyGame package? you can check th eabsolute path by going into your content browser, navigating or searching for your HUD swf movie that you've imported and right click on it and select "Copy path" or something along thos elines .. paste what you find and match it with the line above

    Comment


      #3
      I didn't get it to work. A warning comes up when I compile the code: Warning: ObjectProperty GFxUI.GFxMoviePlayer:MovieInfo: unresolved reference to 'SwfMovie'Flash.MyGame.HUD' '

      The path to my swf file are ..\..\UDKGame\Flash\MyGame\HUD.swf so how would I write it in the code?

      Comment


        #4
        MovieInfo=SwfMovie'MyGame.HUD'

        Means the SWF is in the MyGame package, and it is called HUD. What package did you import your SWF into? And what is its name? Replace MyGame.HUD with that information.

        Comment


          #5
          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

          Comment


            #6
            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.

            Comment


              #7
              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.

              Comment


                #8
                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.

                Comment


                  #9
                  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...

                  Comment


                    #10
                    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

                    Comment


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

                      Comment


                        #12
                        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'

                        Comment


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

                          Comment


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

                            Comment


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

                              Comment

                              Working...
                              X