So I basically want to have an object at a set speed which at a press of a button will have a smooth acceleration boost for 2sec then drop back down to its normal speed
I’ve tried a simple way which basically changes the speed by a multiple then returning it back to its original speed but that messes with the lerp function I use to have a smooth travel by jerking the object backwards to a earlier position.
journeyLength = Vector3.Distance(startPoint, endPoint);
if(acceleration){
var distCovered = (Time.time - startTime) * speed * 2;
}
else{
var distCovered = (Time.time - startTime) * speed;
}
var fracJourney = distCovered / journeyLength;
transform.position = Vector3.Lerp(startPoint, endPoint, fracJourney);