Hello, I have been trying my best to work this out on my own but after half a day still cannot get it to work. Can someone please help to see what’s wrong?
And my code:
zoomAction = playerInput.actions["Zoom"];
void Update()
{
if (zoomAction.IsPressed())
{
float zoomDelta = zoomAction.ReadValue<float>();
AdjustZoom(zoomDelta);
}
}
The error: I don’t understand the error at all. I am not reading the value as Vector2, I am reading it as float!
InvalidOperationException: Cannot read value of type 'Vector2' from composite 'UnityEngine.InputSystem.Composites.AxisComposite' bound to action 'Player/Zoom[/Keyboard/w,/Keyboard/s]' (composite is a 'Int32' with value type 'float')
The documentation doesn’t show binding keyboard keys as example, but I assumed it should work the same as gamepad buttons.
https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/ActionBindings.html#1d-axis