Announcement

Collapse
No announcement yet.

Scaleform and mouse cursor

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

  • replied
    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?

    Leave a comment:


  • replied
    It's me again

    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 ****
    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

    Leave a comment:


  • replied
    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/20...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");

    Leave a comment:


  • replied
    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.

    Leave a comment:


  • replied
    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!

    Leave a comment:


  • replied
    Still trying to figure this out.
    Anyone at all?

    Leave a comment:


  • replied
    Originally posted by Kaldrick View Post
    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.

    Leave a comment:


  • replied
    Change TDS_PlayerController with your PlayerController derived class.

    Leave a comment:


  • replied
    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';
    }

    Leave a comment:


  • replied
    Adding a bCaptureMouse=false line at the defaultproperties gives me nothing. Same with bIgnoreMouseInput = true.

    Leave a comment:


  • replied
    You'll need to play with bCaptureMouse in it to get that to happen

    Leave a comment:


  • replied
    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?

    Leave a comment:


  • replied
    Figured it out. I didnt import my .swf right so the script didnt access it. works now.

    Leave a comment:


  • replied
    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.

    Code:
    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';
    }
    Code:
    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.

    Leave a comment:


  • replied
    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?

    Leave a comment:

Working...
X