void Update()
{
position.x += Input.GetAxis ("Horizontal") * carSpeed * Time.deltaTime;
position.x = Mathf.Clamp (position.x, -2.3f, 2.3f);
transform.position = position;
},
Basically you want to check if a certain time has passed since the key was pressed, and then execute an action right?
this should do that:
public float MaxTime;
private float timer;
private void Update()
{
if (Input.GetAxisRaw("Horizontal") != 0)
{
if (timer > MaxTime)
{
//do the stuff here
}
else
{
timer += Time.deltaTime;
}
}
else
{
timer = 0;
}
}
keep in mind that this is just a quick solution and not well optimized. You should look into coroutines for that.