Search Unity

ReadValue doesn't apply dead zone to the vlaue

Discussion in 'Input System' started by ODINKONG, Aug 11, 2020.

  1. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    112
    Hello I'm guessing this has a simple answer but I can't seem to figure out the solution. I am getting a vector 2 of a controller's left stick using the following code.
    Code (CSharp):
    1. playerinput.currentActionMap.FindAction("Move").performed += ctx => LSInput = ctx.ReadValue<Vector2>();
    The value that ends up in LSinput can be above the dead zone max value and below the dead zone min value. This happens even if I use a processor for the dead zone instead of the default settings.

    Am I using the wrong command for this?
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    That would be expected behavior. The deadzone processor re-normalizes to [0..1] outside the deadzone range. In other words, if, say, your deadzone is min=0.1 and max=0.9, then values are clamped between those two values and the resulting [0.1..0.9] value is mapped to [0..1].
     
  3. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    112
    Ah ok sorry for the silly questions haha. My left stick vector 2 wasn't zeroing out when let go. That was a helpful confirmation though. I guess my dead zone values just weren't thick enough.
     
  4. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    112
    Oh actually it wasn't really the dead zones I realized that with this event only my keyboard controls were getting stuck in one direction. I am also reading the value when movement is canceled now and that seems to have fixed both issues even if use a more shallow dead zone. Thanks for the help.