Joystick axis does not reset after being used.

kinifikinifi Posts: 6Member
Example: LX = Left Joystick X Axis and it equals 0 at start. If I move the joystick left LX = 1. If I let go of the joystick after it equals 1 then the joystick moves back to the middle and my hands are not touching it at all and LX = 1.54342E. 

Any idea how to fix this? 

Comments

  • DreamwriterDreamwriter Posts: 768Member
    edited June 2013
    The final controllers have no built-in deadzone, so you need to program your game to have one.  That's what it looks like his happening there, it's ending up at a very small fraction rather than 0 (centering springs are never going to be perfect).
    Post edited by Dreamwriter on
  • kinifikinifi Posts: 6Member
    I'm sure I could figure this out with time but how I would I program a deadzone? 
  • kinifikinifi Posts: 6Member
    Or can I just find the axis in Unity Input and ad a deadzone? 
  • DreamwriterDreamwriter Posts: 768Member
    edited June 2013

    Basically what you want to do is ignore values below a certain value - like, below 0.15 and greater than -0.15, and then scale the rest of the range by that amount if you care about sensitivity.  There's more detail on implementing dead zones in the Analogue Stick State of the World thread:

    http://forums.ouya.tv/discussion/1275/analog-stick-state-of-the-world

    Post edited by Dreamwriter on
  • kinifikinifi Posts: 6Member
    edited June 2013
    I think you may be confused or I am reading this wrong. I'm getting a greater number when letting go of the joystick then if I pressed the joystick all the way to the left. 

    Basically what you want to do is ignore values below a certain value - like, below 0.15 and greater than -0.15, and then scale the rest of the range by that amount if you care about sensitivity.  There's more detail on implementing dead zones in the Analogue Stick State of the World thread:

    http://forums.ouya.tv/discussion/1275/analog-stick-state-of-the-world


    Post edited by kinifi on
  • kinifikinifi Posts: 6Member
    I think I figured it out. I'll post my solution soon! 
  • tgraupmanntgraupmann Posts: 2,869Administrator, Team OUYA
    Essentially like this

    if (Mathf.Abs(OuyaExampleCommon.GetAxis(LX, player1)) > 0.25f)
    {
    //do game stuff...
    }
    else
    {
    //in the dead zone...
    }
    ~Tim Graupmann
    OUYA Inc | Android Developer
    Skype: tgraupmann_prey

    http://github.com/ouya/docs
    http://github.com/ouya/ouya-sdk-examples

    Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]

    Use caution when setting [persistent wireless mode].
  • Killa_MaakiKilla_Maaki Posts: 504Member
    edited June 2013
    kinifi said:
    I think you may be confused or I am reading this wrong. I'm getting a greater number when letting go of the joystick then if I pressed the joystick all the way to the left.
    Actually, no you're not. You misread the number

    1.54342E. <-- see that letter? That means it's in Engineering notation. It's displayed like this when it's either very large or very small.

    I'm actually willing to bet you didn't copy the whole thing. ToString on a float would never return this, because it's in the right range to display as a regular decimal. I'm willing to bet it actually looks something like this:

    1.54342E-5 (the five was pulled straight from thin air, but you get the idea of what it looks like)

    The number I just wrote actually comes out to:

    0.000154342
    Post edited by Killa_Maaki on
    You didn't remember the plot of the Doctor Who movie because there was none; Just a bunch of plot holes strung together.
Sign In or Register to comment.