Search Unity

Any JoyStick axis also works as arrow keys Help

Discussion in 'Editor & General Support' started by Xenoneq, Feb 17, 2020.

  1. Xenoneq

    Xenoneq

    Joined:
    Feb 11, 2018
    Posts:
    10
    So i have expirienced a problem that I don't know the solution for.

    I am making a party play game. So i t is required to have more
    ways for player to be controlling the player. Today I have discovered that
    my player (which is set to move with arrowkeys) is also moving when
    rotating left analog which is used to move player with gamepad

    My way to check how the player should move is by checking the value of an integer.
    ================================================================
    float moveinput;
    // wsad
    if(controllernumber == 0)
    {
    moveinput = Input.getAxis("Horizontalad")
    }
    // wsad
    if(controllernumber == 1)
    {
    moveinput = Input.getAxis("Horizontalarrow")
    }
    if(controllernumber == 2)
    {
    moveinput = Input.getAxis("Horizontalpad1")
    }
    if(controllernumber == 3)
    {
    moveinput = Input.getAxis("Horizontalpad2")
    }
    if(controllernumber == 5)
    {
    moveinput = Input.getAxis("Horizontalpadetc")
    }
    ==============================================================

    I don't think it's just about my input system buy with Unity
    or my gamepad.
    When I want to detect if player pressed KeyCode.RightArrow for
    example it also works for pad.
     
  2. Xenoneq

    Xenoneq

    Joined:
    Feb 11, 2018
    Posts:
    10
    Also i am sending this if you want to check if I have done something wrong. movemoent script.PNG horizontallarrow.PNG joystick.PNG
    also I know that gamepads should have JoyStick Axis instead of Key or mouse button
    but either way it doesn't work.

    Using key or moise button makes my moveinput go into 1 smoothly same like on keyboard
     
  3. Xenoneq

    Xenoneq

    Joined:
    Feb 11, 2018
    Posts:
    10
    Ok so i found the problem but I don't know how to fix it.
    The problem is steam. If I have turned on steam it sets some kind
    of "deafult controlls" to my gamepad and sets the right analog to work
    as arrow keys. WellI could pradobly fix that relativly quick byy just
    disabling it but what about everyone else playing my game?
    That is the problem! So i need some heelp/
    I am going to check this problem on other pc in my home that have steam installed.
    Maybe it's not a deafult setting.
     
  4. olse30_unity

    olse30_unity

    Joined:
    Oct 10, 2021
    Posts:
    1
    Hey. The Problem is, that the steam id for your test app is by default a game called "Spacewar". For this game inside steam the settings hide your controller to your game.
    1. Import your game to steam (also possible with test games)
    2. Search in your games for "Spacewar"
    3. Go to the games properties (right click on the game)
    4. Go to controller section
    5. Select "deactivate steam input"

    As soon as you have bought your own game on steamworks, the controllers should work without changing the settings manually

    Have fun