diff --git a/Assets/Script/Input/Bindings/AxisBinding.cs b/Assets/Script/Input/Bindings/AxisBinding.cs index 013a43450..49cd6331b 100644 --- a/Assets/Script/Input/Bindings/AxisBinding.cs +++ b/Assets/Script/Input/Bindings/AxisBinding.cs @@ -164,6 +164,13 @@ public override void UpdateState(double time) InvokeStateChanged(State); } + public override void ResetState() + { + RawState = default; + State = default; + InvokeStateChanged(State); + } + private float CalculateState(float rawValue) { float max; diff --git a/Assets/Script/Input/Bindings/ButtonBinding.cs b/Assets/Script/Input/Bindings/ButtonBinding.cs index ceb542689..70d2c8203 100644 --- a/Assets/Script/Input/Bindings/ButtonBinding.cs +++ b/Assets/Script/Input/Bindings/ButtonBinding.cs @@ -164,6 +164,14 @@ public override void UpdateState(double time) InvokeStateChanged(State); } + public override void ResetState() + { + PreviousState = default; + State = default; + _debounceTimer.Stop(); + InvokeStateChanged(State); + } + private float CalculateState(float rawValue) { return rawValue * _invertSign; diff --git a/Assets/Script/Input/Bindings/ControlBinding.cs b/Assets/Script/Input/Bindings/ControlBinding.cs index d63846244..d85aea868 100644 --- a/Assets/Script/Input/Bindings/ControlBinding.cs +++ b/Assets/Script/Input/Bindings/ControlBinding.cs @@ -193,6 +193,12 @@ public virtual void UpdateState(double time) InvokeStateChanged(State); } + public virtual void ResetState() + { + State = default; + InvokeStateChanged(State); + } + protected void InvokeStateChanged(TState state) { StateChanged?.Invoke(state); @@ -434,6 +440,12 @@ private bool RemoveBindings(Func selector) if (selector(binding)) { removed = true; + + // Reset binding state to prevent phantom inputs + binding.ResetState(); + OnStateChanged(binding, InputManager.CurrentInputTime); + FireStateChanged(); + _bindings.RemoveAt(i); FireBindingRemoved(binding.Control); i--;