Was Able to get mouse coordinates, and log them, but unable to get the cursor (simple crosshair) to follow it; it's still locked on the screen.
Custom Input Class
Code:
class AceMouseInput extends PlayerInput;
Var IntPoint MousePosition;
Event PlayerInput(float DeltaTime)
{
//Handle the mouse and make sure I have a HUD
//if (myHUD != None)
// {
//Get For the aMouseX used in udk, use the PlayerInput.aTurn instead.
MousePosition.X = Clamp(MousePosition.X + aMouseX, 0, myHUD.SizeX);
//Get For the aMouseY used in udk, use the PlayerInput.aLookup instead.
MousePosition.Y = Clamp(MousePosition.Y + aMouseY, 0, myHUD.SizeY);
//}
Super.PlayerInput(DeltaTime);
`Log("MOUSE X is" @MousePosition.X);
`Log("MOUSE Y is" @MousePosition.Y);
}
defaultproperties
{
MouseCursorMaterial=Material'PDUI_Gameplay.PDUI_Gameplay.CursorNormal'
CursorSize=64
}
Custom HUD Class
Code:
class AceHUD extends HUD;
var() Material MouseCursorMaterial;
var() float CursorSize;
var const Texture2D CursorTexture;
// The color of the cursor
var const Color CursorColor;
/*
function UpdateMousePosition()
{
local int x, y;
class'UIRoot'.static.GetCursorPosition(x, y);
PlayerOwner.PlayerInput.aturn = MouseX;
PlayerOwner.PlayerInput.aLookup =MouseY;
//`Log("PDHud::UpdateMouseition" @ Mouse.X @ Mouse.Y);
}
*/
/*
function RenderMouseCursor()
{
// Center the cursor on our cursor position
Canvas.SetPos(MouseX - (CursorSize/2), MouseY - (CursorSize/2));
Canvas.DrawColor = Whitecolor;
Canvas.DrawMaterialTile(MouseCursorMaterial,CursorSize,CursorSize,0,0,1,1);
}
*/
event PostRender()
{
Local AceMouseInput MouseInput;
//UpdateMousePosition();
//RenderMouseCursor();
//Make sure that there is a player controller
If (PlayerOwner != None)
{
`Log("PlayerOwner is" @PlayerOwner);
MouseInput = AceMouseInput(PlayerOwner.PlayerInput);
If (MouseInput != None)
{
Canvas.Setpos(MouseInput.MousePosition.X, MouseInput.MousePosition.Y);
Canvas.DrawColor = Whitecolor;
Canvas.DrawMaterialTile(MouseCursorMaterial,CursorSize,CursorSize,0,0,1,1);
}
super.PostRender();
}
}
function Vector GetMouseWorldLocation()
{
local AceMouseInput MouseInterfacePlayerInput;
local Vector MousePosition;
local Vector MouseWorldOrigin, MouseWorldDirection, HitLocation, HitNormal;
// Ensure that we have a valid canvas and player owner
if (Canvas == None || PlayerOwner == None)
{
return Vect(0, 0, 0);
}
// Type cast to get the new player input
MouseInterfacePlayerInput = AceMouseInput(PlayerOwner.PlayerInput);
// Ensure that the player input is valid
if (MouseInterfacePlayerInput == None)
{
return Vect(0, 0, 0);
}
// We stored the mouse position as an IntPoint, but it's needed as a Vector2D
MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
// Deproject the mouse position and store it in the cached vectors
Canvas.DeProject(MousePosition);
// Perform a trace to get the actual mouse world location.
Trace(HitLocation, HitNormal, MouseWorldOrigin + MouseWorldDirection * 65536.f, MouseWorldOrigin , true,,, TRACEFLAG_Bullet);
return HitLocation;
}
defaultproperties
{
MouseCursorMaterial=Material'PDUI_Gameplay.PDUI_Gameplay.CursorNormal'
CursorSize=64
}
PlayerController
Code:
class AcePlayerController extends UTPlayerController;
defaultproperties
{
InputClass=class'Ace_Vehicles.AceMouseInput'
}
I think everything is referenced, and the only link that is missing is the one that connects the mouse cursor to the crosshair.
As always, advice is appreciated!
Bookmarks