Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How do you add a Processor to an InputAction at runtime?

Discussion in 'Input System' started by DK_A5B, Jul 31, 2020.

  1. DK_A5B

    DK_A5B

    Joined:
    Jan 21, 2016
    Posts:
    21
    I'm trying to figure out how to implement a setting that allows the player to control whether the Y-axis input is inverted for a Vector2 action.

    It's easy enough to do this at configuration time, as you can simply add an InvertVector2 processor to the InputAction, and you're all set. However, I don't want to permanently set the Y-axis to inverted, instead I want the player to be able to toggle whether the Y-axis is inverted while playing. The problem is that this requires modifying the InputAction at runtime rather than edit time, and after reading through the documentation I can't see how to modify the processors on an InputAction at runtime. Is this possible? Or do I need to remove the existing action and create a new one?
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,387
    This isn't great ATM. An API to set parameters on actions dynamically is coming.

    ATM it generally requires writing processors that read out their configuration from global state. E.g. having a SensitivityProcessor that reads a "sensitivity" configuration setting.

    The only alternative with the current API is to set binding overrides using
    InputBinding.overrideProcessors
    .
     
  3. DK_A5B

    DK_A5B

    Joined:
    Jan 21, 2016
    Posts:
    21
    Thanks for the response. I ended up going down the binding overrides route in the end. That works fine-ish for now, but I look forward to better support down the road.
     
unityunity