Skip to content

Commit 4f07a69

Browse files
committed
Do nothing if decay input is zero
1 parent b98bda3 commit 4f07a69

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Runtime/Processors.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using UnityEngine;
1+
using UnityEngine;
22

33
namespace Zigurous.Math
44
{
@@ -104,10 +104,12 @@ public static float AxisDeadzone(float input, float min = 0.125f, float max = 0.
104104
/// </summary>
105105
public static float Decay(float input, float decayRate, float zero = 0.0f)
106106
{
107-
if (input >= zero) {
108-
return System.Math.Max(input - (decayRate * Time.deltaTime), zero);
107+
if (input > zero) {
108+
return Mathf.Max(input - (decayRate * Time.deltaTime), zero);
109+
} else if (input < zero) {
110+
return Mathf.Min(input + (decayRate * Time.deltaTime), zero);
109111
} else {
110-
return System.Math.Min(input + (decayRate * Time.deltaTime), zero);
112+
return input;
111113
}
112114
}
113115

0 commit comments

Comments
 (0)