No announcement yet.

Hardware Cursor

  • Filter
  • Time
  • Show
Clear All
new posts

    Hardware Cursor

    Hello everybody,

    we're using Scaleform for drawing an in-game mouse cursor. However, as the framerate drops down, so does the movement of the mouse cursor. Is there any possibility of drawing a hardware cursor using the UDK?

    This is what we've got:

    hwhud_mouse.fla with a MovieClip called mouseCursor and the following ActionScript code:

    var mouseListener:Object = new Object();
    mouseListener.onMouseMove = function ()
    	mouseCursor._x = _root._xmouse;
    	mouseCursor._y = _root._ymouse;
    An UnrealScript class that is set up by the HUD with the following code:

    // ============================================================================
    // HWGFxHUD_Mouse
    // The movie clip providing a mouse cursor that is drawn on-top of the HUD.
    // Related Flash content: UDKGame/Flash/HWHud/hwhud_mouse.fla
    // Author:  Nick Pruehs
    // Date:    2011/05/04
    // (C) 2011 2nd Reality Studios. All Rights Reserved.
    // ============================================================================
    class HWGFxHUD_Mouse extends GFxMoviePlayer;
    /** The mouse cursor of the HUD. */
    var GFxObject MouseCursor;
    function bool Start(optional bool StartPaused = false)
    	local bool bLoadErrors;
    	bLoadErrors = super.Start(StartPaused);
    	// initialize this movie clip without actually advancing the movie
    	// don't scale mouse cursor
    	// ensure mouse cursor is always on top
    	MouseCursor = GetVariableObject("mouseCursor");
    	MouseCursor.SetBool("topmostLevel", true);
    	`log("ยงยงยง GUI: "$self$" has been started.");
    	return bLoadErrors; // (b && true = b)
    Changing the TimingMode didn't fix the issue... Any further ideas?

    we still need a hardware cursor.
    If we want to make a strategy game with Unreal Engine we need a hardware cursor like any other strategy game or else fail.


      I'm still new but since you're still suck and nobody's commented, I might as well chip in. I'm new to Scaleform, but I have a background in flash.

      I don't know if you can use a hardware mouse, but I can think of 2 alternatives that could improve the speed of your mouse.
      1. Use updateAfterEvent to temporarily boost the redraw rate.
      2. See if a Canvas HUD can be used on top of the Scaleform HUD.

      The onMouseMove event gets triggered as fast as flash can handle it, rather than once per frame. So it could be moving the mouse graphic 10 times before the screen refreshes.
      When placed inside of onMouseMove, updateAfterEvent will tell flash the redraw the screen - regardless of the frame rate. So every time the mouse moves, the screen refreshes and you shouldn't get any jerky movement.
      onMouseMove = function (){
          mouse_mc._x = _xmouse;
          mouse_mc._y = _ymouse;
      Technical Note: This won't affect the rate of onEnterFrame events or the speed of other animations. This is because the 'frame rate' in flash controlls the rate of code execution, rather than the refresh rate directly (though the code tells it to refresh the screen). onMouseMove is different because it get's triggered independantly of the frame rate.

      I'm unsure of all the technical stuff behind ScaleForm, but boosting the redraw rate could be terribly inefficient if it updates the whole HUD rather than just the mouse.

      The second option I thought of is drawing the mouse with a Canvas HUD, which should be much quicker - if it's possible to do this. I think I remember seeing that the Scaleform HUD sits on top of or extends a Canvas, so maybe you can draw the mouse just fine there. Or perhaps it's possible to have a Canvas overlay the ScaleForm HUD.

      There might not be a solution here and perhaps there is a way to use a hardware mouse. But I hope I've got the ball rolling at least.


        Thank you very much. I'm sure Nick will take a look at it soon after a few days off. Hostile Worlds has got some huge opportunities to become a real AAA title and this might fix one of the last problems for us to make sure that our prototype and Unreal can make it.

        We might need someone like you for our project by the end of the year. So keep learning


          hm i should have tested this half a year ago, i remember some scaleform doc was saying it converts into a hardware cursor or something

          but i just now capped the engine to 30fps & my custom cursor is indeed 30fps

          what i personally want to know is how to use the OS cursor just like borderlands (which is also a hardware cursor, unaffected by framerate)


            Thank you for your answers!

            Unfortunately, modifying the function called on the onMouseMove event as you suggested doesn't change anything, nor does drawing the mouse cursor using the UDK Canvas (which obviously depends on the game's frame rate).

            Any other ideas?


              You may be able to render a canvas cursor along with the flash UI, but i am not entirely sure how sending the click events across would work out. I am not entirely sure you can render the Canvas UI at the same time and on top, but it should work out. The Canvas functions are still in UDK.


                Ah that's a shame. Thinking about it, updateAfterEvent will probably only boost upto the framerate of the game (not sure what the default is for UDK).
                I did a quick google and found this site where the guy's posted the source for his project. I've searched his name on the forum and found this thread about said project.
                I haven't had a look at it myself, but the comments have been good.


                  You can render a Canvas UI with a scaleform one at the same time, that's sure, and Canvas will not disappear from UDK because of the deproject functionnality. And you can render a Canvas UI over a scaleform UI, i think playing with the drawhud or postrender can do the trick, i think that for exemple, stats fps displays over scaleform


                    I think their problem is that if the cursor is rendered on a canvas, it's limited to whatever framerate the game is running at, so the mouse might appear laggy.
                    A hardware mouse would be rendered independently though, so it would be very smooth.

                    Here is an example of a software mouse running at 30 fps - not too bad, but sometimes it's noticable when you're trying to use it very quickly in a game.
                    Here is an example of one running at (probably) 12 fps - terrible.

                    Final Fantasy 14 was using a software mouse for a while and had loads of complaints. Any time you went into a busy area and the framerate dropped a little bit, the mouse became very unresponsive.

                    Might be worth bringing this topic up again in the 'Programming and Unrealscript' category or something.


                      Originally posted by Captain Zazz View Post
                      I did a quick google and found this site where the guy's posted the source for his project. I've searched his name on the forum and found this thread about said project.
                      I haven't had a look at it myself, but the comments have been good.
                      Any ideas which UDK version that one is built on? The authors don't answer that question


                        why does it matter?


                          First, I want to check it out above a clean UDK installation to check whether the mouse cursor is limited by the game's framerate, or not.

                          And second, it not, I need to know which ActionScript version the whole project is build on.


                            You can get access to both of those things without even opening up his UPK. Scaleform is requiring AS2.0, it is doubtful that anything that his package has deviates from that requirement.


                              Well Scaleform is requiring AS2, but doesn't the current UDK support AS3? I'm wondering whether the mouse cursor behaviour has changed in that major release...

                              Apart from that, can anybody tell if the SimLand mouse cursor movement is limited by the game's framerate, or not?