- Home /
Lerping...Change Speed During Lerp?
Hi, Im creating a game that needs a moving train for a mission. I have all the points where the track changes direction marked in an array using empty game objects. Im using lerp to move the train model from the points, however I want the speed of the train to change based on player input. How would I go about doing this. Im using the lerp code found on the official docs: http://docs.unity3d.com/ScriptReference/Vector3.Lerp.html
On the docs it says the speed is here:
float distCovered = (Time.time - startTime) * speed; <-------
However what if I want to change speed in the middle of 2 points?
Answer by Kaljo · Jul 03, 2015 at 09:02 PM
Vector3.Lerp as a third argument has a fraction value. You need to calculate that value relative to train speed. Like this, when speed value changes, so will fraction value of Lerp method.
Your answer
Follow this Question
Related Questions
rotate object by list values 0 Answers
MouseWheel Lerp Smoothing Problem 1 Answer
Can my lerp-function be optimized? 1 Answer
Unity 2D Scripted Movement 2 Answers
Smoothly move player over a collection of checkpoints 0 Answers