Code:
function PlayerTick(float DeltaTime)
{
local MT_MouseInterfacePlayerInput MouseInterfacePlayerInput;
local IntPoint MousePosition;
local Quat QuatRotation, myQuatRotation;
// Cast to get the MouseInterfacePlayerInput
MouseInterfacePlayerInput = MT_MouseInterfacePlayerInput(PlayerInput);
PlayerCamera.ViewTarget.POV.Location += PlayerViewOffset;
if (MouseInterfacePlayerInput != None)
{
// To retrieve/use the mouse X position
MousePosition.X = MouseInterfacePlayerInput.MousePosition.X;
// To retrieve/use the mouse Y position
MousePosition.Y = MouseInterfacePlayerInput.MousePosition.Y;
}
myRotation = Rotation;
QuatRotation = QuatFromRotator( Rotation );
myQuatRotation = QuatFromRotator( myRotation );
//Roll
if(PlayerInput.aStrafe > 0)//MousePosition.X > (LastHUDSizeX * 0.5) + (LastHUDSizeX * 0.1))
{
myQuatRotation = QuatFromAxisAndAngle( vect(1,0,0), DeltaTime * PlayerInput.aStrafe * -1);
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
else if(PlayerInput.aStrafe < 0)//MousePosition.X < (LastHUDSizeX * 0.5) - (LastHUDSizeX * 0.1))
{
myQuatRotation = QuatFromAxisAndAngle( vect(1,0,0), DeltaTime * PlayerInput.aStrafe * -1);
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
//auto rotate function
//if mouse inside the dead zone
if(MousePosition.X < (LastHUDSizeX * 0.5) + (LastHUDSizeX * 0.1) && MousePosition.X > (LastHUDSizeX * 0.5) - (LastHUDSizeX * 0.1)
&& MousePosition.Y < (LastHUDSizeY * 0.5) + (LastHUDSizeY * 0.1) && MousePosition.Y > (LastHUDSizeY * 0.5) - (LastHUDSizeY * 0.1) )
{
//100 for a buffer so it doesnt alternate super fast
if((myRotation.Roll > 100 && myRotation.Roll < 16200) || (myRotation.Roll > -32667 && myRotation.Roll < -16200))
{
myQuatRotation = QuatFromAxisAndAngle( vect(1,0,0), DeltaTime * TestMoveScale);
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
else if(myRotation.Roll < -100 && myRotation.Roll > -16200 || (myRotation.Roll < 32667 && myRotation.Roll > 16200))
{
myQuatRotation = QuatFromAxisAndAngle( vect(1,0,0), DeltaTime * -TestMoveScale);
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
}
//Yaw
if(MousePosition.X > (LastHUDSizeX * 0.5) + (LastHUDSizeX * 0.1))
{
myQuatRotation = QuatFromAxisAndAngle( vect(0,0,1), DeltaTime * abs(MousePosition.X - LastHUDSizeX * 0.5)/LastHUDSizeX * TestMoveScale );
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
else if(MousePosition.X < (LastHUDSizeX * 0.5) - (LastHUDSizeX * 0.1))
{
myQuatRotation = QuatFromAxisAndAngle( vect(0,0,1), DeltaTime * abs(MousePosition.X - LastHUDSizeX * 0.5)/LastHUDSizeX * -TestMoveScale );
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
//Pitch
if(MousePosition.Y > (LastHUDSizeY * 0.5) + (LastHUDSizeY * 0.1))
{
//myRotation.Pitch += abs(MousePosition.Y - LastHUDSizeY * 0.5)/LastHUDSizeY * TestMoveScale * DeltaTime;
myQuatRotation = QuatFromAxisAndAngle( vect(0,1,0), DeltaTime * abs(MousePosition.Y - LastHUDSizeY * 0.5)/LastHUDSizeY * TestMoveScale ); //vect(0,1,0)
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
else if(MousePosition.Y < (LastHUDSizeY * 0.5) - (LastHUDSizeY * 0.1))
{
//myRotation.Pitch -= abs(MousePosition.Y - LastHUDSizeY * 0.5)/LastHUDSizeY * TestMoveScale * DeltaTime;
myQuatRotation = QuatFromAxisAndAngle( vect(0,1,0), DeltaTime * abs(MousePosition.Y - LastHUDSizeY * 0.5)/LastHUDSizeY * -TestMoveScale );//vect(0,1,0)
QuatRotation = QuatProduct(QuatRotation, myQuatRotation);
}
QuatRotation = QuatSlerp(QuatFromRotator( Rotation ), QuatRotation, 1, true);
myRotation = QuatToRotator(QuatRotation);
SetRotation(myRotation);
Pawn.SetRotation(myRotation);
super.PlayerTick(DeltaTime);
}
Bookmarks