Search Unity

Question Assigning Sticks from code

Discussion in 'Input System' started by stechmann, Nov 5, 2023.

  1. stechmann

    stechmann

    Joined:
    Feb 24, 2012
    Posts:
    34
    Hi,

    I am trying to make my input configurable via variables in the Unity inspector.

    For example I am doing:

    public Key fireKey = Key.A;
    public GamepadButton fireButton = GamepadButton.A;

    Now I also want to create a variable where I can assign left or right Stick for the input, but am struggling to do so. Basically what I want to write, in analogy, is:

    public Stick walkStick = Stick.Left;

    But there is no such thing.

    What is the equivalent syntax?

    (PS: I know there are other ways to do this through Events etc but I am looking for this exact solution.)
     
    Last edited: Nov 5, 2023
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,925
    Doesn't look like there is any real way to do so. You could simply introduce your own enum and some utility methods to make this distinction.

    Mind you I've always just use the
    InputActionReference
    objects to assign inputs via the inspector.