No announcement yet.

Scaleform HUD and UScript Currency Node script; How to access? Help!!!!!!

  • Filter
  • Time
  • Show
Clear All
new posts

    Scaleform HUD and UScript Currency Node script; How to access? Help!!!!!!


    I have a simple Scaleform HUD set up:

    I got the Health/Energy bar at the time working. I have no idea how to get the currency to increment/decrement for this HUD. Do I accomplish this in AS3 or in UDK? I will have Kismet Nodes set up in UDK to get this to work in my game. Here's what I have for code (including a UScript file called CurrencyNode.uc):

    // Needed for the stage
    // Allows us to use Scaleform
    //Allows us to use the Event.ENTER_FRAME event listener;
    // Declaring the Document class
    class Delta_hud extends MovieClip
    	// Variables that we will be using to show the
    	// player's current and max health
    	public static var currentHealth:int = 100;
    	public static var maxHealth:int = 100;
    	//Constructor will be called the first frame of the game
    	function Delta_hud()
    			// Enables Scaleform
    			Extensions.enabled = true;
    			// Adds an event so that the Update function will
    			// be called every single frame.
    	// Code that we want to run every frame of the game
    	function Update(event:Event)
    			// Update our life's scale to reflect the current
    			// ratio of currentHealth to maxHealth
    			lifebar.scaleX = currentHealth/maxHealth;
    This doesn't include the currency as I don't know how to get this into AS. Here is the CurrencyNode.uc code:

    // extend UIAction if this action should be UI Kismet Action instead of a Level Kismet Action
    class Delta_CurrencyNode extends SequenceAction;
    var() int currencyAdd;
    event Activated()
    	local Delta_Gametype rGame;
    	local WorldInfo rWorld;
    	rWorld = GetWorldInfo();
    	if( rWorld != none)
    		rGame = Delta_Gametype(rWorld.Game);
    		if( rGame != none )
    			rGame.nCurrency += currencyAdd;
    	ObjCategory="Team_Delta Actions"
    	bCallHandler = false;
    How do I get this to work in AS and/or how do I tie this in via UScript (or Kismet) so that the currency node works in the Scaleform HUD? The HUD was created using the tutorial found in Mastering UDK Game Development (chapter 4) by John Doran. Any help would be greatly appreciated asap. Thank you! ^_^

    Without even studying the code, this is really easy to achieve.
    Do most of the work in UnrealScript, keep all of your variables there. Only use Flash movie as a holder for UI graphics, at most use it for UI effects, tweens and so on. On change (and only on change) of corresponding variable (money) simply recalculate the result and change the corresponding AS3 property (in your case, scaleX) in your Flash movie through GFx Widget. Ditch that EnterFrame event. Not needed, slows things down.


      Can you post an example of what the code could look like? That would be very helpful. ^_^


        EDIT: got confused with that currency you keep mentioning and forgot you want a bar working. Will post some code later on.

        EDIT 2:

        In UnrealScript add this function to your GFx HUD wrapper class (obviously you can put it anywhere you want, but then you'll need to correctly instantiate your wrapper class for usage):

        function changeBarSize(int barsize){
        // scaleX should probably be between 0 and 1, but depends on your Flash setup of course

        Obviously, healthBarGFxWidget needs to be initialized properly in your GFx HUD wrapper class like this healthBarGFxWidget = GetVariableObject("_root.healthBar");

        At any rate, don’t just blindly believe me, I really recommend going through the code in UT classes and learn this your own way.


          I don't have any Uscript for this HUD. Here's where I got it from: (chapter 4: Creating a Custom HUD). I have tried countless other tutorials, but none of them have worked (either outdated AS or Uscript). I'm really getting at a loss to get this stuff to work! (See my other posts on the subject.)


            OK I looked at it. Hmmm I never use Kismet in this way, so I am truly unable to help you further. The code I gave you works, but that would mean you getting knee-deep in UScript. It takes time but it's well worth the investment if you are serious about UDK development.