I've got this working so far. It creates an object that represents my physical gaming controller (a Razer Hydra), gets data from the controller, and then turns and moves my pawn.
But as you can probably tell, that code just slides the pawn around on an absolute X,Y plane, and the movement is not relative to the pawn's facing. It also doesn't play the running animation. It's doesn't take into account acceleration or the pawn's ground or water speed. And the pitch and roll will rotate the pawn, but not the camera.
I'm sure I could do the trigonometry on my own to change the model facing and the camera together, then translate my joystick's absolute X,Y into the model's relative X,Y. But I'm sure I would be reinventing the wheel.
Can anyone recommend some reading on how to take my joystick input and make it change the model's direction, move the model relative to its rotation, move the camera with the model, and play the appropriate animations? There have to be functions already written for that, right?
Code:
classMyUnrealGame01PlayerController extends GamePlayerController;
var sixense TheSixense;
defaultproperties
{
CameraClass=class'MyUnrealGame01.MyUnrealGame01Camera'
InputClass=class'MyUnrealGame01.MyUnrealGame01PlayerInput'
}
simulated event PostBeginPlay()
{
super.PostBeginPlay();
TheSixense = new class'Sixense';
TheSixense.sixenseInit();
TheSixense.sixenseGetAllNewestData(TheSixense.TheControllerData);
}
simulated event PlayerTick(float DeltaTime)
{
local vector LeftJoystick;
local rotator RightJoystick;
super.Tick(DeltaTime);
TheSixense.sixenseGetAllNewestData(TheSixense.TheControllerData);
RightJoystick.Yaw = Pawn.Rotation.Yaw + TheSixense.TheControllerData.controller[0].joystick_x * DeltaTime * 4000;
RightJoystick.Pitch = Pawn.Rotation.Pitch + TheSixense.TheControllerData.controller[0].joystick_y * DeltaTime * 4000;
RightJoystick.Roll = Pawn.Rotation.Roll;
Pawn.SetRotation(RightJoystick);
LeftJoystick.X = -TheSixense.TheControllerData.controller[1].joystick_x * DeltaTime * 100;
LeftJoystick.Y = TheSixense.TheControllerData.controller[1].joystick_y * DeltaTime * 100;
Pawn.Move(LeftJoystick);
}
But as you can probably tell, that code just slides the pawn around on an absolute X,Y plane, and the movement is not relative to the pawn's facing. It also doesn't play the running animation. It's doesn't take into account acceleration or the pawn's ground or water speed. And the pitch and roll will rotate the pawn, but not the camera.
I'm sure I could do the trigonometry on my own to change the model facing and the camera together, then translate my joystick's absolute X,Y into the model's relative X,Y. But I'm sure I would be reinventing the wheel.
Can anyone recommend some reading on how to take my joystick input and make it change the model's direction, move the model relative to its rotation, move the camera with the model, and play the appropriate animations? There have to be functions already written for that, right?
Last edited: