Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question TwinStick Controls with Gamepad: 1 Vector2 and 8 component parts?

Discussion in 'Input System' started by Allan-MacDonald, Jan 4, 2024.

  1. Allan-MacDonald

    Allan-MacDonald

    Joined:
    Sep 21, 2015
    Posts:
    114
    upload_2024-1-4_8-29-7.png

    I'm pretty sure this is the default action Unity provides out of the box, how do they intend that you work with this? I haven't been able to figure out how to differentiate between bindings and use those for different things because the context.ReadValue doesn't seem to allow me to point to a specific binding. I did have luck completely bypassing the callback param and doing two seperate Gamepad.current.rightStick / lightStick, but I want to use the provided callback so I have access to rebinding etc later.

    Any tips? Currently I just have one action per action, the above image looks to me like two actions in one, so you could XZ move the character and rotate the camera with the other stick. I can't figure out how to do with though with context.readvalue, and haven't seen this done in any samples provided by unity either. I did look at their warriors sample project, and they have a InputProvider component on their Cinemachine FreeLook camera, but that just hooks it up automagically and I want to know how it works, or how they intend for us to do it typically without cinemachine's help.

    Thanks!
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,178
    Just make left and right stick separate actions. No need to leave things default. Alter them to your project.
     
  3. Allan-MacDonald

    Allan-MacDonald

    Joined:
    Sep 21, 2015
    Posts:
    114
    @spiney199 sure, I did.. but I'm curious how to do it the combined way, i havent been able to figure out how to do it.
     
  4. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,178
    Why? Not only is it the wrong way to do it, you either can't or it would be pointlessly complicated.

    One InputAction should refer to one action. One action for movement, one action for aiming.
     
  5. Allan-MacDonald

    Allan-MacDonald

    Joined:
    Sep 21, 2015
    Posts:
    114
    So its officially not intended to work on the binding level?
     
  6. Allan-MacDonald

    Allan-MacDonald

    Joined:
    Sep 21, 2015
    Posts:
    114
    Why does it come out of the box that way then, thats misleading at best?
     
  7. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,178
    No. The input system is a layer of abstraction between the action and the inputs that correspond to it. Namely, it means you don't need to care about the specific inputs, and only have to care about the action they handle.

    So an InputAction refers to one action, and can (and often will) have multiple inputs that trigger it. You should only care about registering to the actions, and not care about the individual buttons.

    I'm fairly certain you're looking at the UI action map of the default input action map asset. Which is, unsurprisingly, set up for simple UI navigation, not game-play.

    I'm 99% sure the default map has separate "Move" and "Look" inputs for the default gameplay inputs, as seen here: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/manual/ActionAssets.html#editing-actions

    So I don't think there's anything misleading, you've just confused yourself somehow.
     
  8. Allan-MacDonald

    Allan-MacDonald

    Joined:
    Sep 21, 2015
    Posts:
    114
    @spiney199 thanks! Yes likely, I took their LStick & RStick under one navigation action as twin stick, not two options to do the same thing, navigate through menus.. but I guess that is fine for demonstration purposes on their end.
     
    spiney199 likes this.