Input system doesn't seem to be recognizing control type properly?

I have an action defined as:

Action Type: “Value”
Control Type: “Integer”

It’s bound to a couple of buttons on my gamepad:

Then in my code I’m trying to read the value of the input as an int:

int stabilize = stabilizeAction.ReadValue<int>();
Debug.Log($"Stabilize: {stabilize}");

When I press the button, I get an exception:

InvalidOperationException: Cannot read value of type 'int' from control '/XInputControllerWindows/rightShoulder' bound to action 'Drone/Stabilize[/XInputControllerWindows/leftShoulder,/XInputControllerWindows/rightShoulder]' (control is a 'ButtonControl' with value type 'float')
UnityEngine.InputSystem.InputActionState.ReadValue[TValue] (System.Int32 bindingIndex, System.Int32 controlIndex, System.Boolean ignoreComposites) (at Library/PackageCache/com.unity.inputsystem@1.0.0/InputSystem/Actions/InputActionState.cs:2020)
UnityEngine.InputSystem.InputAction.ReadValue[TValue] () (at Library/PackageCache/com.unity.inputsystem@1.0.0/InputSystem/Actions/InputAction.cs:934)
Com.SadnessMonday.Drone.DroneControl.ProcessInput () (at Assets/Scripts/DroneControl.cs:248)
Com.SadnessMonday.Drone.DroneControl.Update () (at Assets/Scripts/DroneControl.cs:223)

It seems like Unity thinks the control is set as a ButtonControl with type float? What am I doing wrong?

1 Like

I opted to make it a normal Button control and just go event-based. But I feel like making an int-value-based button should work. Is that not supported?

1 Like