I’m trying to switch to the new Unity Input System and running into an issue.
I want to set up a simple hotbar system where the event returns a value and that value is used to determine which hotbar button should be highlighted.
I don’t want to set up seperate events for each numerical button from 1 to 0. I would much more prefer to assign value to keybindings and use same event for all of them.
using something like this for it:
public void OnHotbarInteract(InputAction.CallbackContext value)
{
int hotbarIndex = Mathf.RoundToInt(value.ReadValue<float>());
inventory.MakeActive(SlotIndex[hotbarIndex]);
ChangeHightlight(inventory.ActiveSlot.slotDisplay);
}
Problem is, the value in this system always defaults to 0, no matter if I’m using axis, or vector or even any value and modify it using keybindings.
This makes sense for continuous input like mouse or player movement but does not really work for other inputs.
No matter if I’m using Clamps or Scaling it, it will always immediately try to return to value 0. I can somewhat control it by using Tap or Press Interactions. But if I hold those buttons they will default to 0 anyways.
So, is there a way to set the value and not update it until next input, esentially disabling defaulting to 0 ?
Or am I approaching this from a wrong angle ?