Xbox controller input bug

Hello,
I’ve been trying to make my game work with an xbox controller, i kinda got it working, everything works execept for some axis which i need to invert.
But it’s moving by itself without any input.
i have displayed the input on the screen and as you can see if acts weird.
Once i stop giving input unity just goes back to a default input as it seems.

I really hope someone can help me out!

This is the code

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {

    public static float mouseSensitivityX = 200f;
    public static float mouseSensitivityY = 200f;
    public static float walkSpeed = 8f;
    public GameObject cameraT;
    Rigidbody rb;

    Vector3 moveAmount;
    Vector3 smoothMoveVelocity;

    float verticalLookRotation;
    // Use this for initialization
    void Start () {
        rb = GetComponent<Rigidbody>();
    }
 
    // Update is called once per frame
    void Update () {
        transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * Time.deltaTime * mouseSensitivityX);
        verticalLookRotation += Input.GetAxis("Mouse Y") * Time.deltaTime * mouseSensitivityY;
        verticalLookRotation = Mathf.Clamp(verticalLookRotation, -60, 60);
        cameraT.transform.localEulerAngles = Vector3.left * verticalLookRotation;

        Vector3 moveDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
        Vector3 targetMoveAmount = moveDir * walkSpeed;
        moveAmount = Vector3.SmoothDamp(moveAmount, targetMoveAmount, ref smoothMoveVelocity, .15f);
    }

    void FixedUpdate()
    {
        rb.MovePosition(rb.position + transform.TransformDirection(moveAmount) * Time.fixedDeltaTime);
    }
}

Its not a ‘bug’ it has to do with the hardware registering values from the analog sticks as they may not be pristine. To solve this, you need to add a dead zone. If you are using the InputManager (which I think you are) increase the deadZone value. I usually use 0.2F.

Actually you are using GetAxisRaw, which will give you the value of the axis without applying the dead zone to it.

When using an analog stick, it is good practice to use GetAxisRaw, yet apply the deadzone yourself, so you get a more natural deadzone.

Here is a great thread explaining this : Casino software guide everything you need to know - Third Helix

Try putting these values in for Gravity, Dead Zone, Sensitivity:
2653953--187040--Input.png

Alright, thanks for the replies!
It was indeed the dead zone,
i managed to get it working expect for the Y axis of the left joystick, i am 100% sure that i have set the deadzone for it, but it is still keeping a constant value above 0, the rest works properly

1 Like

EDIT: It only keeps a constant value above 0 when i slightly push the joystick, so when i push it all the way it doesn’t do it.

1 Like

Does it work in here? It shows deadzones and such.