Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Trouble jumping on joystick Y axis

Discussion in 'Editor & General Support' started by Valasty, Feb 5, 2016.

  1. Valasty

    Valasty

    Joined:
    Aug 22, 2013
    Posts:
    125
    Hello!

    I'm struggling to get this thing fixed, but I do not seem very close to a solution...

    So, I'm building a Smash Bros like 2D game, and the goal is to move characters around with Left and Right, and jump with Up. The code and input managers works perfectly for up to two different players using the same keyboard, but I want to get a controller working. The code is simple:

    Code (csharp):
    1. if (touchingGround && Input.GetButtonDown(jump))
    2.   rigidb2D.AddForce(new Vector2(0, jumpForce));
    3.  
    I managed to make the characters move left and right just fine using the joystick axis, and I also made the jump work upon a joystick key press (e.g. pressing X), but I want to jump using axis up.

    I tried replacing the code to "Input.GetAxis(jump) > 0.001f", but for some reason the GetAxis debugs into 0 > 1 > 0 > 1 > 0 > 1 (or -1) even when I'm not pressing anything (no idea why).

    The ideal would be a specific key to use when the axis is moved up (like "joystick button up" or something), but I don't think there is such option.

    I ran out of ideas, I tried a lot of configs and codes, but none seem to work. Can someone please lend me a hand on this? (I can provide screenshots or more info if necessary)
     
  2. Valasty

    Valasty

    Joined:
    Aug 22, 2013
    Posts:
    125
    Anyone? :(
     
  3. Valasty

    Valasty

    Joined:
    Aug 22, 2013
    Posts:
    125
    Sorry for another repost but... no ideas? :/
     
  4. Valasty

    Valasty

    Joined:
    Aug 22, 2013
    Posts:
    125
    Ok... last time I try, I promisse. No one?
     
  5. stickylab

    stickylab

    Joined:
    Mar 16, 2016
    Posts:
    92
    vis
    visible sadfusion