Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Input System and Axis Dead Zone

Discussion in 'Input System' started by CyberAngel, Jul 17, 2019.

  1. CyberAngel


    Oct 4, 2014
    Now I am going to use the premise that I have a robot, that when I push in a direction, he turns around and begins moving in that direction. The issue I seem to be having, is when I released the left stick it is sometimes flicking to a different direction.

    So if I push in the NE direction or up and right, then obviously he turns and moves in that direction, but as soon as I release the stick he should stay in that direction.

    I am assuming this might be solved with the dead zone setting some how, wold I be correct in that assumption and if so, would anyone have values that I should be using.

    I can't seem to find much information on the dead zone and how it works.
  2. wolfybytes


    Aug 22, 2014
    I'm having this same issue. It looks like pressing left will give me a vector 2 input (1.0, 0.0) and pushing right will give me (0.0, 1.1). Seems like my controller (I'm using an xbox one controller) isn't giving any input that's negative, when creating input using a directional Vector2, the values range from -1.0 to 1.0, left would be (-1.0, 0.0) and right would be (1.0, 0.0).

    Not sure where the issue is, but setting a deadzone could fix the problem? Not sure.
  3. CyberAngel


    Oct 4, 2014
    That was my thinking as well, but I am not sure....

    I have the following code.

    Code (CSharp):
    1. private void Awake()
    2. {
    3.     gamepadControls.GamePlay.Rotate.performed += ctx => Rotate = new Vector3(ctx.ReadValue<Vector2>().x, ctx.ReadValue<Vector2>().y, 0);
    4. }
    6. void Update()
    7. {
    8.     float heading = Mathf.Atan2(Rotate.y, -Rotate.x) * Mathf.Rad2Deg;
    9.     transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(new Vector3(0, heading - 90, 0)), Time.deltaTime * rotationSpeed);
    10. }
    The sole thing this code is supposed to do, is if I push up then it rotates the object to up or the direction I move it.

    The issue is, when I do push up and then release the Right Stick, it will sometime move from that position. For example sometimes when I push up and release it, the object will then maybe rotate to down. I never pushed down, but it ends up rotating and pointing in that direction. It is almost like the values being read from the axis is wrong.

    In other examples, it might move 5-20degree's left or right where I released the stick, which is kind of expected and why I am asking about the deadzone here. But this doing a 180 degree flip is really weird because that is almost like the stick is saying that when I released it I pushed the stick down as I released it.

    And the 5-20 degree movement is important as well, because I can't find a way to push up, rotate the object to that position and release the stick and that is where the object stays rotated.