View Full Version : Scaleform and mouse cursor
edx76
08-23-2010, 03:46 AM
Hi,
I'm new to UDK. I've read that using Scaleform, you can create menus and HUD for a game. Few things I'd like to know:
1 - Is it possible to display a mouse cursor on screen while in game with scaleform, specially with a game extending from ut classes? The only tutorials I know about that are X9 production tutorials (which doesn't use scaleform and doesn't work for me with classes extending from UT classes - dont know why) and pieces of codes from RTS Framework, which work fine but doesn't use Scaleform.
2 - Is it possible to get mouse world coordinates (deprojection of 2D mouse cursor coordinates), using the same kind of code as I read in RTS framework or on X9 production site?
When I say: "is it possible?", I mean: is there a video showing it or a piece of code available on these forums I could learn from?
Any information much appreciated. Thanks.
xGallox
08-23-2010, 04:07 AM
1- Is possible, you can do it in the same way it is done in any flash application.
2- Is possible, and the X9 tutorial is a good solution. You can find more about mouse projection in this tutorial http://unrealmindset.wordpress.com/2010/04/29/mouse-projecting/
edx76
08-23-2010, 03:56 PM
Thanks a lot. I already saw your blog and thought it was very interesting work but I didn't saw this article. I'll read it.
Kitese
08-23-2010, 06:49 PM
This is how my Scaleform mouse works.
In Flash:
1. A new movieclip symbol with imported bitmaps as the cursor images.
2. An instance of this movieclip on the main stage in it's own layer.
3. Following AS in the first frame of the mouse layer:
import flash.external.ExternalInterface;
// Hide normal "Windows" pointer.
Mouse.hide();
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function ()
{
// Set the cursor instance position to the mouse position.
MouseCursorInstance._x = _root._xmouse;
MouseCursorInstance._y = _root._ymouse;
// Tell our UnrealScript about the new mouse coords.
ExternalInterface.call( "ReceiveMouseCoords", _root._xmouse, _root._ymouse );
updateAfterEvent();
};
Mouse.addListener(mouseListener);
In Unrealscript:
A GFxMoviePlayer class for the HUD movie:
class Tds_GFxHud extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Init( PlayerController PC )
{
Start();
Advance(0.0f);
SetFocus( false, true );
}
// This is called from Flash.
function ReceiveMouseCoords( float x, float y )
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff = false
bGammaCorrection = false
// Path to your package/flash file here.
MovieInfo = SwfMovie'TrGfx.TrHudMain'
}
The HUD class the uses the movie:
class Tds_Hud extends UDKHUD;
var Tds_GFxHud HudMovie;
var class<Tds_GFxHud> HudMovieClass;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
HudMovie = new HudMovieClass;
HudMovie.PlayerOwner = Tds_PlayerController(PlayerOwner);
HudMovie.SetTimingMode( TM_Real );
HudMovie.SetViewScaleMode( SM_NoScale );
HudMovie.SetAlignment( Align_BottomCenter );
HudMovie.Init( HudMovie.PlayerOwner );
// When using scaleform these seem to be set to 0?
SizeX = 1280.0f;
SizeY = 720.0f;
}
singular event Destroyed()
{
if( HudMovie != none )
{
HudMovie.Close( true );
HudMovie = none;
}
super.Destroy();
}
function Vector2d GetMouseCoords()
{
local Vector2d mousePos;
mousePos.X = HudMovie.MouseX;
mousePos.Y = HudMovie.MouseY;
return mousePos;
}
event PostRender()
{
local Vector2D playerMouse;
local Tds_PlayerController tdsPlayer;
tdsPlayer= Tds_PlayerController(PlayerOwner);
playerMouse = GetMouseCoords();
Canvas.SetDrawColor( 255, 255, 255, 255 );
Canvas.SetPos( 10.0, 10.0 );
Canvas.DrawText( "Mouse: X:" $ playerMouse.X $ ", Y:" $ playerMouse.Y );
// ** Can do the deproject etc. as shown in tutorials here on the values from GetMouseCoords().
}
DefaultProperties
{
HudMovieClass = class'Tds_GFxHud'
}
A screenshot (http://i.imgur.com/XZjFw.png) of the result.
edx76
08-23-2010, 07:22 PM
Great! That's exactly what I'm looking for.
Which classes do you extend from for your pawn, playercontroller and gameinfo?
Is it possible for you to deproject cursor coordinates to get world mouse position?
Doublezer0
08-24-2010, 06:43 AM
or you could extend my simple Flash Scaleform Cursor class to suit. I like The methods you used there Kitese for the situation you required. Nice
edx76
08-24-2010, 04:18 PM
Thanks, guys. I'll have a look at all this stuff.
Hytek
10-21-2010, 01:31 PM
Unfortunately it doesnt seem like SetFocus is in the september build of udk, what can we use instead?
zero4
11-16-2010, 07:37 AM
1. A new movieclip symbol with imported bitmaps as the cursor images.
2. An instance of this movieclip on the main stage in it's own layer.
Is there any chance that someone can tell us how to do that? :) Steep by step. I will be grateful!
Nanorock
12-03-2010, 12:24 PM
Is there any chance that someone can tell us how to do that? :) Steep by step. I will be grateful!
I also clearly would like that to be explain :s
Nanorock
12-04-2010, 07:27 AM
Hi,
I'm having trouble with the default MovieInfo,
I get this error when I compile
Z:\UDK\Development\Src\RC\Classes\RCGFxHud.uc(36) : Warning, ObjectProperty GFxUI.GFxMoviePlayer:MovieInfo: unresolved reference to 'SwfMovie'RC.menu''
Z:\UDK\Development\Src\RC\Classes\RCGFxHud.uc(36) : Warning, Invalid property value in defaults: MovieInfo = SwfMovie'RC.menu'
While I've definitively added my menu.swf and menu.fla in :
[game directory]/UDKGame/Flash/RC/
I had import swf with command 'udk gfximport RC/menu.swf' with no error.
Here is my GFxMoviePlayer Class
class RCGFxHud extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Init(optional LocalPlayer LocPlay )
{
LocalPlayerOwnerIndex = class'Engine'.static.GetEngine().GamePlayers.Find( LocPlay);
if(LocalPlayerOwnerIndex == INDEX_NONE)
{
LocalPlayerOwnerIndex = 0;
}
if( MovieInfo != None )
{
if( bAutoPlay )
{
Start();
Advance(0.f);
SetPriority(1);
}
}
}
// This is called from Flash.
function ReceiveMouseCoords( float x, float y )
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff = false
// Path to your package/flash file here.
MovieInfo = SwfMovie'RC.menu'
}
Please if anyone can help, I need a mouse T.T
Thanks !
Nanorock
12-04-2010, 11:56 AM
Ok, I've managed to get rid of warning and error during compilation.
And now it work.
I had to import my .swf with udk content browser, and move it in the UDKHUD package in order to correctly have the .swf loaded via unrealScript. Why my package didn't work ... don't know -_-
Anyway I've got a mouse ! cheers !
dpsygnet
12-04-2010, 08:00 PM
Anyone got it to work with the november release ? i got an error about
...\Classes\PZOGfxHUD.uc(6) : Error, Redefinition of 'function Init' differs from original
:(
Nanorock
12-05-2010, 05:39 AM
Look at init function of the parent ... it's not the same ! And it must be the same ;)
dpsygnet
12-05-2010, 08:19 AM
I did that previously and got a whole lot more different errors in frontend. Can you post your working code so i can compare ?
dpsygnet
12-05-2010, 02:40 PM
Figured out that they removed Player Owner, invalidating most of the code. Anyone can rewrite one using the new GetPC function ? i tried but failed after many trial and error.
Figured out that they removed Player Owner, invalidating most of the code. Anyone can rewrite one using the new GetPC function ? i tried but failed after many trial and error.
try this
HudMovie.Init(HudMovie.GetLP());
not PC! Because function Init(optional LocalPlayer LocPlay) in GFxMoviePlayer class and your init function must be same or you get error
dpsygnet
12-11-2010, 08:15 AM
I did thank you but i still have a lot of errors
..\PZOGfxHUD.uc(11) : Error, 'SetFocus': Bad command or expression
...\PZOHUD.uc(51) : Error, Bad or missing expression for token: PZOPlayerController, in '='
...\PZOHUD.uc(33) : Error, Cannot call 'Super' of final function 'Destroy'
...\PZOHUD.uc(12) : Error, Unrecognized member 'PlayerOwner' in class 'PZOGfxHUD'
Im not sure what am supposed to do, ill mess around but if someone can help me on it that woul be awesome.
dpsygnet
12-11-2010, 08:39 AM
Managed to get no error or warning but the mouse wont show. Do i need to add something in my maine game .uc file ?
Here are my files, can anyone help me fix the problemes ?
notes: the flash actionscript is the same as from first page. also I imported the swf in the UDKHUD package as someone suggested that it wont work elsewhere.
PZOGfxHUD.uc
class PZOGfxHUD extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Init(optional LocalPlayer LocPlay)
{
Start();
Advance(0.0f);
// SetFocus( false, true );
}
// This is called from Flash.
function ReceiveMouseCoords( float x, float y )
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff = false
bGammaCorrection = false
// Path to your package/flash file here.
MovieInfo = SwfMovie'UDKHud.PZOGfxHUDCursor'
}
PZOHUD.uc
class PZOHUD extends UDKHUD;
var PZOGfxHUD HudMovie;
var class<PZOGfxHUD> HudMovieClass;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
HudMovie = new HudMovieClass;
//HudMovie.PlayerOwner = TPZOPlayerController(GetLP());
HudMovie.SetTimingMode( TM_Real );
HudMovie.SetViewScaleMode( SM_NoScale );
HudMovie.SetAlignment( Align_BottomCenter );
HudMovie.Init(HudMovie.GetLP());
//HudMovie.Init( HudMovie.PlayerOwner );
// When using scaleform these seem to be set to 0?
SizeX = 1280.0f;
SizeY = 720.0f;
}
singular event Destroyed()
{
if( HudMovie != none )
{
HudMovie.Close( true );
HudMovie = none;
}
Destroy();
}
function Vector2d GetMouseCoords()
{
local Vector2d mousePos;
mousePos.X = HudMovie.MouseX;
mousePos.Y = HudMovie.MouseY;
return mousePos;
}
event PostRender()
{
local Vector2D playerMouse;
local PZOPlayerController PZOPlayer;
//PZOPlayer = PZOPlayerController(GetLP());
playerMouse = GetMouseCoords();
Canvas.SetDrawColor( 255, 255, 255, 255 );
Canvas.SetPos( 10.0, 10.0 );
Canvas.DrawText( "Mouse: X:" $ playerMouse.X $ ", Y:" $ playerMouse.Y );
// ** Can do the deproject etc. as shown in tutorials here on the values from GetMouseCoords().
}
DefaultProperties
{
HudMovieClass = class'PZOGFxHud'
}
thundyr
12-12-2010, 11:29 PM
I'm not certain whether it will fix your problem, but I had an issue that my mouse cursor would not track the mouse until I had this in my HUD.uc:
function vector2D GetMouseCoordinates()
{
local Vector2d mousePos;
mousePos.X = HudMovie.GetVariableNumber("_root._xmouse");
mousePos.Y = HudMovie.GetVariableNumber("_root._ymouse");
return mousePos;
}
the flash actionscript is the same as from first page. also I imported the swf in the UDKHUD package as someone suggested that it wont work elsewhere
AS works fine, just put your .swf file to 'UDK\UDKGame\Flash\NameOfYourHUDPackage\'
Also all content used in yours swf should be in a folder 'UDK\UDKGame\Flash\NameOfYourHUDPackage\NameOfYour SWF\'
dpsygnet
12-13-2010, 12:39 PM
AS works fine, just put your .swf file to 'UDK\UDKGame\Flash\NameOfYourHUDPackage\'
Also all content used in yours swf should be in a folder 'UDK\UDKGame\Flash\NameOfYourHUDPackage\NameOfYour SWF\'
I will try that thank you, but it still doesn't fix the playerowner problem. I replaced the HudMovie.Init(HudMovie.GetLP()); but it gives me error about all the other line refering to Playerowner. I changed them to GetLP but i still have more and more error.
Anyone can simply take my code and try to get it to work, and post it here so that everyone can get a functional mouse cursor ?
this works for me:
GFx class
class GFxWHUD extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Initialize()
{
Start();
Advance(0.0f);
}
function ReceiveMouseCoords(float x, float y)
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff=FALSE
bEnableGammaCorrection=FALSE
MovieInfo=SwfMovie'WUI.HUD'
}
HUD:
var GFxWHUD HudMovie;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
if (HudMovie == None)
{
HudMovie = new class'WGame.GFxWHUD';
HudMovie.Initialize();
}
SizeX = 1024;
SizeY = 768;
}
function vector2D GetMouseCoordinates()
{
mousePos.X = HudMovie.MouseX;
mousePos.Y = HudMovie.MouseY;
return mousePos;
}
If it doesn't help, give me your code, I will look, than I can help
dpsygnet
12-13-2010, 06:21 PM
Thank you, nearly worked :)
was getting a error
(21) : Error, 'mousePos': Bad command or expression
had to add
local Vector2d mousePos;
above mousepos, no more error now
Still cannot see my mouse through :(
My .swf is located in ///\Development\Src\PZO\Flash
my gfx class says
MovieInfo=SwfMovie'PZO.PZOGfxHUDCursor'
and in UDK in my content browser the path of my swf is
..\..\UDKGame\Flash\PZO\PZOGfxHUDCursor.swf
is it supposed to be alright ?
also i created my flash file as Actionscript 3 , should i select As2 instead ?
am kind of lost as to why it is not working.
lordshtzu
12-13-2010, 06:51 PM
Thank you, nearly worked :)
now i get the error
(21) : Error, 'mousePos': Bad command or expression
on your HUD class are you extending UDKHUD or something else ?
That's just because he forgot to declare mousePos at the top of GetMouseCoordinates, just add:
local Vector2D mousePos;
at the top of GetMouseCoordinates.
My .swf is located in ///\Development\Src\PZO\Flash
The swf needs to be in UDKGame\Flash\PZO I think, and that's where you should import it from into your package in UDK. That is pretty much how my files are set up and it works fine.
srv's code works well, but I do have a different problem with it. Despite having:
SizeX = 1024;
SizeY = 768;
And despite the fact that the resolution of the window is indeed 1024x768, the coordinates I get from the ReceiveMouseCoords function are in the range of 800x600 (which is what the flash movie is authored in).
This breaks things like DeProject, although I can work around it by scaling the coordinates like so:
mousePos.X = HudMovie.MouseX / 799.0f * Canvas.ClipX;
mousePos.Y = HudMovie.MouseY / 599.0f * Canvas.ClipY;
Where Canvas.ClipX is 1024 and Canvas.ClipY is 768.
Anyway, like I said I can work around it, but I was wondering if there's a way to get the coordinates out of flash in the resolution of the game, not the flash movie, since it seems like this would be a pain when supporting mutliple resolutions.
dpsygnet
12-13-2010, 07:31 PM
I double checked and my .swf is actually in UDKGame\Flash\PZO
I redid my flash as actionscrupt 2 but it still wont work. It's frustrating, i have no error , the problem could be anywhere and everything !
anything special in the way you create your cursor ?
are you changing the resolution of the scene ?
I created a movie clip and imported a .tga, added it to the librarym, added the tga into the movie clip, selected the first frame of the scene, added the actionscript and exported a swf
lordshtzu
12-13-2010, 07:58 PM
We just have a movie clip with the cursor image, and in ActionScript on the clip we have added:
onClipEvent (mouseMove)
{
_x = _x + _xmouse;
_y = _y + _ymouse;
}
This should make the cursor show up when previewed in Flash as well, it's from the examples of how to get a cursor to work (in flash).
dpsygnet
12-13-2010, 08:37 PM
tryed to replace my flash code with yours and it didn't works :(
Do you have anything related to your mouse in your playercontroller, pawn, main classes ?
I did a quick kismet to play my swf cursor just in case it was a stupid error of it being invisible and i can see it, but it's not moving..
lordshtzu
12-13-2010, 08:40 PM
Nope, nothing like that, it works for us when previewed in Flash as well....
also i created my flash file as Actionscript 3 , should i select As2 instead ?
only AS2 ! AS3 not supported for now as i know
I have created flash HUD the same size as a standard window of start UDK - 1024х768 (these sizes I have applied for SizeX/Y)
dpsygnet, your swf file should is on this path: '.\.\UDKGame\Flash\PZO\'
and content is:
'.\.\UDKGame\Flash\PZO\PZOGfxHUDCursor\'
If all is alright, also yours .png (only PNG, not TGA) file of the cursor with the correct identifier it should be imported itself to library at import swf.
After all it problems with my code shouldn't be.
I think that your problem in an incorrect content path and file extension (should be .png).
lordshtzu, while coordinates in uc are transferred from AS these coordinates will be only concerning the sizes of working area swf
and for Action Script this is my mouse listener and mouse drag code:
import flash.external.ExternalInterface;
Mouse.hide();
var mouseMoveListener:Object = new Object();
mouseMoveListener.onMouseMove = function()
{
ExternalInterface.call("ReceiveMouseCoords", _root._xmouse, _root._ymouse);
updateAfterEvent();
};
Mouse.addListener(mouseMoveListener);
startDrag("cursor_mc", true);
cursor_mc is instance of my cursor movie clip located manually in frame
sorry for my English :)
thundyr
12-15-2010, 05:59 AM
tryed to replace my flash code with yours and it didn't works :(
Do you have anything related to your mouse in your playercontroller, pawn, main classes ?
I did a quick kismet to play my swf cursor just in case it was a stupid error of it being invisible and i can see it, but it's not moving..
Are you still struggling? If so, do you still have this line in your HUD class?
HudMovie.SetViewScaleMode( SM_NoScale );
I also had issues with my mouse cursor until I removed that line.
nemirc
01-05-2011, 04:36 PM
Hello everybody D:
I got my utterly well-drawn cursor to show up in the play window, but I can't move it?I compiled with no errors, but no matter if I move the mouse like crazy, the cursor just stays there.
Any idea why this is happening? D:
collix
01-11-2011, 09:04 AM
Had the same problem like nemirc, but then I figured that I should edit the Actions of my scene (unselect everything and press F9) instead of editing the actions of my movieclip.
Syndrome9001
01-13-2011, 11:41 PM
So, I've been trying for about 4 days to get this to work. I've tried various ways and am currently stuck with the error:
"Warning, ObjectProperty GFxUI.GFxMoviePlayer:MovieInfo unresolved reference to 'SwfMovie'MyIsometricGame.MyHud"
as well as "Invalid property value in defauls: MovieInfo=SwfMovie'MyIsometricGame.MyHud'
I made this account just to ask for help because I'm absolutely LOST!
I was just going through the X9Productions tutorial for making an Isometric Game and (obviously) got to the mouse part, which is no longer valid.
I made my cursor (as a .PNG), imported it in to Flash and use's Srv's actionscript and Instance Name (bottom of page 3) and the mouse functions in flash perfectly. I placed the .Fla and .Swf in UDKGame > Flash > MyIsometricGame (I also tried just adding it in the UDKHud folder) and even added the .PNG to a subfolder with the same name as the .Fla/.Swf.
As for my HUD and GFxMoviePlayer script, I also tried using the code provided by Srv.
Do I need to add anything else in other scripts? I have "HUDType=class'Iso_Hud'" in my GameInfo script, but do I need anything else added? (keep in mind, all the scripting before what Srv provided is what's on the X9 website.)
Is there any chance someone could make a full tutorial that's functional with the latest UDK? That would be amazing and probably get rid of my massive headache, lol.
Thanks in advance.
yaziii
01-14-2011, 01:11 AM
This is how my Scaleform mouse works.
In Flash:
1. A new movieclip symbol with imported bitmaps as the cursor images.
2. An instance of this movieclip on the main stage in it's own layer.
3. Following AS in the first frame of the mouse layer:
import flash.external.ExternalInterface;
// Hide normal "Windows" pointer.
Mouse.hide();
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function ()
{
// Set the cursor instance position to the mouse position.
MouseCursorInstance._x = _root._xmouse;
MouseCursorInstance._y = _root._ymouse;
// Tell our UnrealScript about the new mouse coords.
ExternalInterface.call( "ReceiveMouseCoords", _root._xmouse, _root._ymouse );
updateAfterEvent();
};
Mouse.addListener(mouseListener);
In Unrealscript:
A GFxMoviePlayer class for the HUD movie:
class Tds_GFxHud extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Init( PlayerController PC )
{
Start();
Advance(0.0f);
SetFocus( false, true );
}
// This is called from Flash.
function ReceiveMouseCoords( float x, float y )
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff = false
bGammaCorrection = false
// Path to your package/flash file here.
MovieInfo = SwfMovie'TrGfx.TrHudMain'
}
The HUD class the uses the movie:
class Tds_Hud extends UDKHUD;
var Tds_GFxHud HudMovie;
var class<Tds_GFxHud> HudMovieClass;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
HudMovie = new HudMovieClass;
HudMovie.PlayerOwner = Tds_PlayerController(PlayerOwner);
HudMovie.SetTimingMode( TM_Real );
HudMovie.SetViewScaleMode( SM_NoScale );
HudMovie.SetAlignment( Align_BottomCenter );
HudMovie.Init( HudMovie.PlayerOwner );
// When using scaleform these seem to be set to 0?
SizeX = 1280.0f;
SizeY = 720.0f;
}
singular event Destroyed()
{
if( HudMovie != none )
{
HudMovie.Close( true );
HudMovie = none;
}
super.Destroy();
}
function Vector2d GetMouseCoords()
{
local Vector2d mousePos;
mousePos.X = HudMovie.MouseX;
mousePos.Y = HudMovie.MouseY;
return mousePos;
}
event PostRender()
{
local Vector2D playerMouse;
local Tds_PlayerController tdsPlayer;
tdsPlayer= Tds_PlayerController(PlayerOwner);
playerMouse = GetMouseCoords();
Canvas.SetDrawColor( 255, 255, 255, 255 );
Canvas.SetPos( 10.0, 10.0 );
Canvas.DrawText( "Mouse: X:" $ playerMouse.X $ ", Y:" $ playerMouse.Y );
// ** Can do the deproject etc. as shown in tutorials here on the values from GetMouseCoords().
}
DefaultProperties
{
HudMovieClass = class'Tds_GFxHud'
}
A screenshot (http://i.imgur.com/XZjFw.png) of the result.
in which file i want to place all this code, guide me i am new but not much new and I also want this in my game to make cursor so please if some one clear me would be greatly appreciated.
Matt Doyle
01-14-2011, 01:27 PM
@yaziii -
From what I can tell...
The first code block should go in a FLA/SWF file called: TrHudMain.SWF and this file should be saved in the package: TrGfx
The second code block should go in an UnrealScript class called: Tds_GFxHud.uc
The third code block should go in an UnrealScript class called: Tds_Hud.uc
Matt Doyle
01-14-2011, 01:28 PM
@Syndrome9001 -
It is hard to say for sure what is wrong, without more details, particularly I'd need to see your code. But, it looks like your code is referencing a SWF file that does not exist in the package you say it does.
yaziii
01-14-2011, 02:04 PM
@yaziii -
From what I can tell...
The first code block should go in a FLA/SWF file called: TrHudMain.SWF and this file should be saved in the package: TrGfx
The second code block should go in an UnrealScript class called: Tds_GFxHud.uc
The third code block should go in an UnrealScript class called: Tds_Hud.uc
let us suppose i made SWF file nd save it name TrHudMain.SWF but where is TrGfx package??? i think i want to create new file in UDK and name it TrGfx am i right??? And where is this Tds_GfxHud.uc and Tds_Hud.uc??? and one more think please visit this link also please because you are expert in scaleform HUD etc etc link is here:
http://forums.epicgames.com/showthread.php?t=758521
Matt Doyle
01-14-2011, 02:17 PM
You need to read this to learn how to import a new package & SWF into UDK:
http://udn.epicgames.com/Three/ScaleformImport.html#Importing%20SWFs%20into%20UE3
Essentially - save your SWF file in a folder called TrGfx in the Flash directory of your UDK game directory. The Flash directory already exists. So create the folder TrGfx in there, then save your SWF inside that.
Then, inside UDK Editor, press Import button in Content Browser and import the SWF file.
\UDKGame\Flash\TrGfx
The UnrealScript files should be saved in this folder inside your UDK install:
\Development\Src\UTGame\Classes
yaziii
01-15-2011, 02:29 AM
what should I name the movieclip of mouse and also instance name???
yaziii
01-15-2011, 02:54 AM
You need to read this to learn how to import a new package & SWF into UDK:
http://udn.epicgames.com/Three/ScaleformImport.html#Importing%20SWFs%20into%20UE3
Essentially - save your SWF file in a folder called TrGfx in the Flash directory of your UDK game directory. The Flash directory already exists. So create the folder TrGfx in there, then save your SWF inside that.
Then, inside UDK Editor, press Import button in Content Browser and import the SWF file.
\UDKGame\Flash\TrGfx
The UnrealScript files should be saved in this folder inside your UDK install:
\Development\Src\UTGame\Classes
for this can you make tutorial for me please???
nemirc
01-17-2011, 01:45 AM
Had the same problem like nemirc, but then I figured that I should edit the Actions of my scene (unselect everything and press F9) instead of editing the actions of my movieclip.
I did exactly that, but the mouse does not move. Unless it doesn't work in PIE but in PoPC only?
collix
01-18-2011, 06:45 AM
Well, it works all the time for me, maybe you need to set the Gametype for PIE to your game in Worldproperties of your level?
Tjommi
02-02-2011, 03:50 PM
I cant seem to make this thing work either. Currently my code looks like this. When i run my game i cant see the cursor from flash, also the coordinates from Canvas.DrawText doesnt update either and is stuck on 0.0000, 0.0000.
class TDSGFx_Crosshair extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Initialize()
{
Start();
Advance(0.0f);
}
function RecieveMouseCoordinates(float x, float y)
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff = false;
bEnableGammaCorrection = false;
MovieInfo = SwfMovie'TopDownShooter.TDSHud';
}
class TDSHud extends UDKHUD;
var TDSGFx_Crosshair CrosshairMovie;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
if(CrosshairMovie == none)
{
CrosshairMovie = new class'TDSGFx_Crosshair';
CrosshairMovie.Initialize();
}
SizeX = 1024;
SizeY = 720;
}
singular event Destroyed()
{
if(CrosshairMovie != none)
{
CrosshairMovie.Close(true);
CrosshairMovie = none;
}
Destroy();
}
function Vector2d GetMouseCoords()
{
local Vector2D MouseCoords;
MouseCoords.X = CrosshairMovie.MouseX;
MouseCoords.Y = CrosshairMovie.MouseY;
return MouseCoords;
}
event PostRender()
{
local Vector2D PlayerMouse;
local TDSPlayerController TDSPlayer;
PlayerMouse = GetMouseCoords();
Canvas.SetDrawColor(255,255,255,255);
Canvas.SetPos(10.0,10.0);
Canvas.DrawText("Mouse: X:" $ playerMouse.X $ ", Y:" $ playerMouse.Y);
}
DefaultProperties
{
}
I got 2 layers in my .fla file, one "actions" and one "scene" and the AS code is posted in the first frame of "actions".
any suggestions?
Edit: Ive also tried to change the actionscript to what "srv" suggested but when i do the "startDrag("Crosshair", true);" i get the message "Error: StartDrag of invalid target 'Crosshair'".
i tried to convert the object i had placed on the scene to a "symbol" movieclip and give it the name "Crosshair" but that didnt change anything.
Tjommi
02-03-2011, 08:07 AM
Figured it out. I didnt import my .swf right so the script didnt access it. works now.
Kaldrick
02-15-2011, 02:44 PM
I've made my cursor using Doublezer0's mouse cursor class, but I've got a problem.. Since I load my movie on texture, not on hud, I want my mouse to be moved only when I'm around that BSP object. Right now cursor on that screen moves whenever I move, and clicks whenever I click, even if I'm gazillion miles away. How can I change that?
Blade[UG]
02-15-2011, 02:59 PM
You'll need to play with bCaptureMouse in it to get that to happen
Kaldrick
02-15-2011, 03:02 PM
Adding a bCaptureMouse=false line at the defaultproperties gives me nothing. Same with bIgnoreMouseInput = true.
HadHa
03-03-2011, 05:38 PM
Trying to make this work, but I am not sure what I should edit the error-line to be.
[0010.34] Log: D:\UDK\UDK-2011-01\Development\Src\UDNExamples\Classes\UDNHud.uc(4 8) : Error, Unrecognized type 'Tds_PlayerController'
What is Tds_PlayerController?
Adding some info for easier help =D
Got my sikte.fla and sikte.swf in: ...UDK-2011-01\UDKGame\Flash\UDNHud
and the png in UDK-2011-01\UDKGame\Flash\UDNHud\sikte
UDNHud.uc
class UDNHud extends UDKHUD;
var UDNMoviePlayer HudMovie;
var class<UDNMoviePlayer> HudMovieClass;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
HudMovie = new HudMovieClass;
HudMovie.PlayerOwner = Tds_PlayerController(PlayerOwner);
HudMovie.SetTimingMode( TM_Real );
HudMovie.SetViewScaleMode( SM_NoScale );
HudMovie.SetAlignment( Align_BottomCenter );
HudMovie.Init( HudMovie.PlayerOwner );
// When using scaleform these seem to be set to 0?
SizeX = 1280.0f;
SizeY = 720.0f;
}
singular event Destroyed()
{
if( HudMovie != none )
{
HudMovie.Close( true );
HudMovie = none;
}
super.Destroy();
}
function Vector2d GetMouseCoords()
{
local Vector2d mousePos;
mousePos.X = HudMovie.MouseX;
mousePos.Y = HudMovie.MouseY;
return mousePos;
}
event PostRender()
{
local Vector2D playerMouse;
local Tds_PlayerController tdsPlayer;
tdsPlayer= Tds_PlayerController(PlayerOwner);
playerMouse = GetMouseCoords();
Canvas.SetDrawColor( 255, 255, 255, 255 );
Canvas.SetPos( 10.0, 10.0 );
Canvas.DrawText( "Mouse: X:" $ playerMouse.X $ ", Y:" $ playerMouse.Y );
// ** Can do the deproject etc. as shown in tutorials here on the values from GetMouseCoords().
}
DefaultProperties
{
HudMovieClass = class'UDNMoviePlayer'
}
UDNMoviePlayer.uc
class UDNMoviePlayer extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Initialize()
{
Start();
Advance(0.0f);
//SetFocus( false, true );
}
function RecieveMouseCoordinates(float x, float y)
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff = false;
bEnableGammaCorrection = false;
MovieInfo = SwfMovie'UDNHud.sikte';
}
Kaldrick
03-04-2011, 01:19 AM
Change TDS_PlayerController with your PlayerController derived class.
HadHa
03-04-2011, 10:56 AM
Change TDS_PlayerController with your PlayerController derived class.
Im fairly new to unrealscripting (Had a first glance at it 4-5 days ago) -
Could you be more specific?
I tried using my UDNPlayerController (which I dont think gives much sense) and the PlayerController from development/source/engine - None of them was really helping.
Any help would be appreciated.
HadHa
03-06-2011, 01:09 PM
Still trying to figure this out.
Anyone at all?
Rosicky
10-10-2011, 06:45 PM
Hi, Sorry to bring up an old thread but does anyone have any working examples for this? Maybe including the Game and PlayerController classes? I've got my flash working separately (using the Scaleform Mouse gem thing) but when I try to include it with my existing scripts it just doesn't seem to work. The X and Y Coordinates are in the top left but nothing actually happens with the mouse and no cursor shows.
Thanks for your help!
nemirc
10-10-2011, 09:38 PM
You could try studying (or even modifying) the UDKFrontEnd flash file that ships with UDK. As I recall the entire mouse thing only requires 2 lines of code or so.
Rosicky
10-12-2011, 11:58 AM
Thanks, I've had a go but I still cant get it working. The Flash file I was using was from the Scaleform Mouse gem so I doubt it could be that which was stopping it running correctly.
All I wanted was to have a mouse button move the player - I had it going last year using tutorials but now I've come back to UDK all the tutorials are out of date.
EDIT: Is there any bugs with this? I tried using script from http://zombpir8ninja.blogspot.com/2011/03/d-battlemap-using-udk-fixed-hud.html and got it working okay however I changed a few things and broke it so replaced my edited code back to their original one. Now the mouse will not work at all, the cursor just sits there? It was fine about 10 minutes before and I haven't touched the actual flash files?
EDIT2: Scratch that - I needed to add the following back in:
mousePos.X = CrosshairMovie.GetVariableNumber("_root._xmouse");
mousePos.Y = CrosshairMovie.GetVariableNumber("_root._ymouse");
;)
Rosicky
10-12-2011, 03:52 PM
It's me again :rolleyes:
Can anyone tell me if there is alot more work needed to get a mouse button working for navigation?
Hud:
class BattleMapHUD extends UDKHUD;
var BattleMapGfxHud CrosshairMovie;
var class<BattleMapGfxHud> CrosshairMovieClass;
simulated function PostBeginPlay()
{
super.PostBeginPlay();
if (CrosshairMovie == none)
{
CrosshairMovie = new CrosshairMovieClass;
CrosshairMovie.Initialize();
}
SizeX = 1024.0f;
SizeY = 764.0f;
}
singular event Destroyed()
{
if( CrosshairMovie != none )
{
CrosshairMovie.Close( true );
CrosshairMovie = none;
}
Destroy();
}
function vector2D GetMouseCoordinates()
{
local Vector2D mousePos;
mousePos.X = CrosshairMovie.GetVariableNumber("_root._xmouse");
mousePos.Y = CrosshairMovie.GetVariableNumber("_root._ymouse");
//mousePos.X = CrosshairMovie.MouseX;
//mousePos.Y = CrosshairMovie.MouseY;
return mousePos;
}
event PostRender()
{
local BattleMapPlayerController bmPlayerController;
local vector startTrace;
local Vector endTrace;
local Vector mouseOrigin;
local Vector mouseDirection;
local string StringMessage;
local Vector pawnEyeLocation;
local Rotator pawnEyeRotator;
super.PostRender();
StringMessage = "";
bmPlayerController = BattleMapPlayerController(PlayerOwner);
bmPlayerController.MousePosition = GetMouseCoordinates();
//Deproject the mouse from screen coordinate to world coordinate and store World Origin and Dir.
Canvas.DeProject(bmPlayerController.MousePosition, mouseOrigin, mouseDirection);
if (bmPlayerController.Pawn != none)
{
startTrace = bmPlayerController.Pawn.Location;
startTrace.Z += bmPlayerController.CameraZOffset;
endTrace = startTrace + (mouseDirection * 5000);
Trace(mouseOrigin, mouseDirection, endTrace, startTrace, true);
// laser sight from pawn to reticle
bmPlayerController.Pawn.GetActorEyesViewPoint(pawn EyeLocation, pawnEyeRotator);
Draw3DLine(pawnEyeLocation, mouseOrigin, RedColor);
}
bmPlayerController.SetMouseOrigin(mouseOrigin);
StringMessage = "NetMode=" @ WorldInfo.NetMode @ "\nPlayerController=" @ PlayerOwner @ "\nControllerRotation=" @ bmPlayerController.Rotation @ "\nPawn=" @ PlayerOwner.Pawn @ "\nPawnRotation=" @ bmPlayerController.Pawn.Rotation @ "\nPawnEyeRotation=" @ pawnEyeRotator;
//`Log(StringMessage);
Canvas.DrawColor = GreenColor;
Canvas.SetPos( 10, 10 );
Canvas.DrawText( StringMessage, false, , , TextRenderInfo );
}
DefaultProperties
{
CrosshairMovieClass = class'BattleMapGfxHud'
}
PlayerController:
class BattleMapPlayerController extends UTPlayerController
config(Game);
var int CameraZOffset;
var Vector2D MousePosition;
var Vector MouseOrigin;
simulated function SetMouseOrigin(Vector NewMouseOrigin)
{
MouseOrigin = NewMouseOrigin;
ServerMouseOrigin(NewMouseOrigin);
}
reliable server function ServerMouseOrigin(Vector NewMouseOrigin)
{
MouseOrigin = NewMouseOrigin;
}
// This basically locks the camera to the pawn's location, and adds CameraZOffset to the Z of the camera.
simulated event GetPlayerViewPoint( out vector out_Location, out Rotator out_Rotation )
{
// this right here is just terrible. but after spending days trying to figure out why the server
// thought the client was in 3rd person, but the client thought it was in 1st, I just hacked it.
bBehindView = true;
// let's just ignore all the fancy crap
if(Pawn == None)
super.GetPlayerViewPoint(out_Location, out_Rotation);
else
out_Location = Pawn.Location;
out_Location.Z += CameraZOffset;
out_Rotation = rotator(vect(0,0,-1));
}
// Force WASD to be NWSE, so use world rotation instead of pawn rotation
state PlayerWalking
{
function PlayerMove( float DeltaTime )
{
local vector X,Y,Z, NewAccel;
local eDoubleClickDir DoubleClickMove;
local rotator OldRotation;
local bool bSaveJump;
if( Pawn == None )
{
GotoState('Dead');
}
else
{
// Changed this:
//GetAxes(Pawn.Rotation,X,Y,Z);
GetAxes(WorldInfo.Rotation,X,Y,Z);
// Update acceleration.
NewAccel = PlayerInput.aForward*X + PlayerInput.aStrafe*Y;
NewAccel.Z = 0;
NewAccel = Pawn.AccelRate * Normal(NewAccel);
DoubleClickMove = PlayerInput.CheckForDoubleClickMove( DeltaTime/WorldInfo.TimeDilation );
// Update rotation.
OldRotation = Rotation;
UpdateRotation( DeltaTime );
bDoubleJump = false;
if( bPressedJump && Pawn.CannotJumpNow() )
{
bSaveJump = true;
bPressedJump = false;
}
else
{
bSaveJump = false;
}
if( Role < ROLE_Authority ) // then save this move and replicate it
{
ReplicateMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
}
else
{
ProcessMove(DeltaTime, NewAccel, DoubleClickMove, OldRotation - Rotation);
}
bPressedJump = bSaveJump;
}
}
}
// This makes our weapons aim to the pawn's rotation, not the controller's rotation
function Rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
{
local Vector pawnEyeLocation;
local Rotator pawnEyeRotator;
if(Pawn != None)
{
//return Pawn.Rotation;
Pawn.GetActorEyesViewPoint(pawnEyeLocation, pawnEyeRotator);
return Rotator(MouseOrigin - pawnEyeLocation);
}
else return Rotation;
}
// Turn the pawn toward the cursor
function UpdateRotation( float DeltaTime )
{
local Rotator NewRotation, ViewRotation; //DeltaRot
ViewRotation = Rotation;
if (Pawn!=none)
{
ViewRotation = Rotator(MouseOrigin - Pawn.Location + (Pawn.EyeHeight * vect(0,0,1)));
Pawn.SetDesiredRotation(ViewRotation);
}
//// Calculate Delta to be applied on ViewRotation
//DeltaRot.Yaw = PlayerInput.aTurn;
//DeltaRot.Pitch = PlayerInput.aLookUp;
//ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
//SetRotation(ViewRotation);
SetRotation(ViewRotation);
ViewShake( deltaTime );
NewRotation = ViewRotation;
NewRotation.Roll = Rotation.Roll;
if ( Pawn != None )
Pawn.FaceRotation(NewRotation, deltatime);
}
// Make sure our custom HUD is used
reliable client function ClientSetHUD(class<HUD> newHUDType)
{
if ( myHUD != None )
{
myHUD.Destroy();
}
//myHUD = (newHUDType != None) ? Spawn(newHUDType, self) : None;
myHUD = (newHUDType != None) ? Spawn(class'BattleMap.BattleMapHUD', self) : None;
}
DefaultProperties
{
CameraZOffset=480
}
GFxMoviePlayer:
class BattleMapGFxHud extends GFxMoviePlayer;
var int MouseX;
var int MouseY;
function Initialize()
{
Start();
Advance(0.0f);
}
// This is called from Flash.
function ReceiveMouseCoords( float x, float y )
{
MouseX = x;
MouseY = y;
}
DefaultProperties
{
bDisplayWithHudOff = false
// Path to your package/flash file here.
MovieInfo = SwfMovie'MouseInterfaceContent.MouseInterfaceCurso r'
}
The mouse works okay for the player rotation although its not central (north and south are out in x), however my main problem now is getting a mouse button to work for movement instead of WASD etc..
Thanks for the help
fingolfin
10-18-2011, 10:15 PM
I followed Allar's cursor tutorial and now my mouse works quite fine. Here is the tutorial: http://www.youtube.com/watch?v=6VkP7JgYH4k
He uses startDrag function but the problem is, mouse lags a bit when imported to UDK. Anything to fix that?
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.