Hey guys,
I am trying to learn how to properly code a xbox controller to work. I have been using the unity/hololens controller example to learn from but one I am still having one issue with having the Analog Sticks for movement and looking that use Local position over world position. It took me a minute to figure out how to change the LeftThumbstickY() to affect the Z axis over the Y Axis. But it seems to be world coordinates.I was able to get the desired move effects using the D-Pad buttons, but I am unsure how to get it using the Analogs sticks with the Thumbstick Inputs. Any advice?
float moveHorizontal = MoveHorizontalSpeed * controllerInput.GetAxisLeftThumbstickX();
float moveVertical = MoveVerticalSpeed * controllerInput.GetAxisLeftThumbstickY();
this.transform.Translate(moveHorizontal, 0.0f, moveVertical);
float rotateAroundY = RotateAroundYSpeed * controllerInput.GetAxisRightThumbstickX();
float rotateAroundX = RotateAroundXSpeed * controllerInput.GetAxisRightThumbstickY();
float rotateAroundZ = RotateAroundZSpeed * (controllerInput.GetAxisRightTrigger() - controllerInput.GetAxisLeftTrigger());
this.transform.Rotate(-rotateAroundX, rotateAroundY, rotateAroundZ);
if (controllerInput.GetButton(ControllerButton.DPadUp))
this.transform.localPosition += Main.transform.forward;
if (controllerInput.GetButton(ControllerButton.DPadDown))
this.transform.localPosition -= Main.transform.forward;
if (controllerInput.GetButton(ControllerButton.DPadLeft))
this.transform.localPosition -= Main.transform.right;
if (controllerInput.GetButton(ControllerButton.DPadRight))
this.transform.localPosition += Main.transform.right;