i am trying to accelerate a car over time. when the a key is pressed, it passes a targetVelocity of 5.0 i want that car to accelerate to that value slowly over time using math.lerp, I just can’t seem to get it to work. This code causes the car to travel at a constant velocity.
public void MoveCar(float targetVelocity){
transform.position += transform.right * (Mathf.Lerp(0.0f, targetVelocity, Time.deltaTime * 3.0f));
}
Where do you call this method ? See : - https://unity3d.com/learn/tutorials/modules/beginner/scripting/linear-interpolation - http://answers.unity3d.com/questions/998544/having-difficulty-with-lerp.html
– HelliumThis is what you want. http://gamedev.stackexchange.com/questions/102303/2d-c-collecting-item-for-acceleration-unity/102435#102435
– savlon