Static utility for mapping analog input to digital directions. Defines a deadzone constant, returns signed digital forward/left values based on Input.AnalogMove with a 0.75 threshold, and exposes ForwardDown and BackDown booleans.
using System;
namespace Skateboard.Utils;
public static class InputLD
{
public const float kDeadzone = 0.75f;
public static float DigitalForwardInput
{
get
{
if ( Math.Abs( Input.AnalogMove.x ) <= 0.75f )
{
return 0f;
}
return Math.Sign( Input.AnalogMove.x );
}
}
public static float DigitalLeftInput
{
get
{
if ( Math.Abs( Input.AnalogMove.y ) <= 0.75f )
{
return 0f;
}
return Math.Sign( Input.AnalogMove.y );
}
}
public static bool ForwardDown => DigitalForwardInput > 0f;
public static bool BackDown => DigitalForwardInput < 0f;
}