Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Mapping to Button South - however action only happens when pressing Button North on Joypad

Discussion in 'Input System' started by Meguchi, Jan 2, 2021.

  1. Meguchi

    Meguchi

    Joined:
    Nov 22, 2016
    Posts:
    4
    Hi

    I am relatively new to Unity and especially this new Input System so please bear with me if this is something obvious.

    I have setup a button press action for Jump as follows:

    upload_2021-1-2_21-49-22.png

    And in code I am referencing/actioning it as follows:
    Code (CSharp):
    1. if (Input.GetButtonDown("Jump"))
    2. {
    3.      ...
    4. }
    However, the player will only ever jump when I actually press the north button. This is the case for no matter which button I set in the Input Controller (East, West, South and North). The player will only ever jump when the North button is pressed.

    Please let me know if there is any more info I could provide but am wondering if anyone else has experienced this. I am at a bit of a loss here. I am using an X-Box USB controller (it is probably about 8 years old by now) but not expecting that to be a problem.
     
  2. Meguchi

    Meguchi

    Joined:
    Nov 22, 2016
    Posts:
    4
    I am kicking myself as I think I realise the problem is simply that the C# I am using is for the old Input System and not using the new one....! DOH! I will update and reply accordingly.
     
  3. Meguchi

    Meguchi

    Joined:
    Nov 22, 2016
    Posts:
    4
    Yeah, after instantiating the PlayerActionControls object in the C# script, I replaced the above code with the following:

    Code (CSharp):
    1.         float jumpButtonPressed = playerActionControls.Player.Jump.ReadValue<float>();
    2.  
    3.         if (jumpButtonPressed == 1 && isGrounded)
    And all seems to work fine as expected! Schoolboy error!