Top down 3d shooter script, xbox 360 controller assistance

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?

Never mind, had to go back into the Input Manager and set the types to Joystick Axis.
EDIT

Actually in case anybody else does come read this, new problem…

  1. The character doesn’t stop moving once I stop the input on the left stick, even increasing my drag and angular drag isn’t stopping this.
  2. Any input on the right stick (The rotation) causes the player to move.

I think I may wind up rebuilding the movement / rotation from scratch.

Take a look at your DeadZone. Also here’s some reading:

2 Likes

Yeah I was just tweeking those, thanks for the link I’ll go check that out now.

Edit
Wow, that’s actually a really good read. Bookmarking that. Thanks again.