You want two variables:
currentLane
desiredLane
When you process user input, you set desiredLane
to what it should be.
Every Update()
you use Mathf.MoveTowards()
(or Vector.MoveTowards()
) to move currentLane
gradually to desiredLane
.
You want two variables:
currentLane
desiredLane
When you process user input, you set desiredLane
to what it should be.
Every Update()
you use Mathf.MoveTowards()
(or Vector.MoveTowards()
) to move currentLane
gradually to desiredLane
.