I want to slow down the acceleration of the axis input.
Instead of the analogue stick detecting the 0-1 input instantly, I want to introduce lag so that it will take a few more seconds for the input to be received.
Would anyone know how to go about this?
Thank you
Here is a quick example. Just uses a ramp up speed and also decelerates by itself if no axis is being used.
using UnityEngine;
public class SpeedThings : MonoBehaviour
{
float speed;
float rampUp = 0.5f; // How fast we get speed forward/backward
float deceleration = 0.5f; // How fast we decelerate when we are no longer gaining speed
void Update()
{
float inputDelta = Input.GetAxis("Vertical");
if (inputDelta == 0)
{
speed = Mathf.MoveTowards(speed, 0f, deceleration * Time.deltaTime);
}
else
{
speed += inputDelta * rampUp * Time.deltaTime;
}
// You can clamp the speed if you wish
speed = Mathf.Clamp(speed, -1f, 1f);
Debug.Log(speed);
}
}
Hope it gives you some ideas. Good luck.