So here’s what I have in my Update function for a simple 3d top down shooter using C#.
Vector3 inputMove = new Vector3 (Input.GetAxisRaw ("leftStickHorizontal"), 0, Input.GetAxisRaw ("leftStickVertical"));
Vector3 inputRotate = new Vector3 (Input.GetAxisRaw ("rightStickHorizontal"), 0, Input.GetAxisRaw ("rightStickVertical"));
if (inputRotate != Vector3.zero) {
targetRotation = Quaternion.LookRotation (inputRotate);
transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle (transform.eulerAngles.y, targetRotation.eulerAngles.y, rotationSpeed * Time.deltaTime);
}
Vector3 motion = inputMove;
motion *= (Mathf.Abs (inputMove.x) == 1 && Mathf.Abs (inputMove.z) == 1) ? .7f : 1;
motion *= (Input.GetKey (KeyCode.LeftShift)) ? runSpeed : walkSpeed;
motion += Vector3.up * -8;
controller.Move (motion * Time.deltaTime);
I did go into the input manager and set up the 4 stick inputs, on the x, y, 4th, and 5th axes (4 and 5 are for the right stick).
So far all that’s happening is my character will move left and right, but not up nor down, and won’t rotate at all.
Yes it probably would’ve been a lot easier using the mouse to rotate the player, but I really just wanted to get full controller functionality at the moment.
Thoughts?