Hello everyone,
As stated in the Input System Manual “Input Actions are designed to separate the logical meaning of an input from the physical means of input… You can write code that is agnostic to where the input is coming from”.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Actions.html
I’m currently converting from the old input system in order to make use of this modularity, so instead of reading e.g. gamepad axis data like:
A: look = gamepad.rightStick.ReadValue();
I try to:
B: myControls.gameplay.look.performed +=
context => look = context.ReadValue<Vector2>();
While case A provides a constant input reading it lacks the modularity, making it necessary to write device specific code. Case B on the other hand provides the device independency but appears to limit its capabilities primarily because (I assume) it’s based on state of events.
In other words I find it hard to comprehend how an event would be generated if, for example, a gamepad stick is held still at some percentage away from the center. It seems like in practice, small stick movements generate “.performed” events which seem to be as inconsistent as the gamepads’ internal mechanism jitter, making the overall response appear non-linear.
Further down the Input System manual another method of reading events is described:
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Events.html
In the “Reading State Event” section the following code is suggested for reading directly from devices using event pointers.
InputSystem.onEvent +=
(eventPtr, device) =>
{
// Ignore anything that isn't a state event.
if (!eventPtr.IsA<StateEvent>() && !eventPtr.IsA<DeltaStateEvent>())
return;
var gamepad = device as Gamepad;
if (gamepad == null)
{
// Event isn't for a gamepad or device ID is no longer valid.
return;
}
var leftStickValue = gamepad.leftStick.ReadValueFromEvent(eventPtr);
};
In this case the data reading seems consistent but I can’t find a way to associate this with the actual Action (e.g. typical Move or Aim).
How should I approach this matter? Can I keep both the modularity and the responsiveness?
Thanks for reading!