Answers for "Lerp between two Vectors"
http://answers.unity.com/questions/730755/lerp-between-two-vectors.html
The latest answers for the question "Lerp between two Vectors"Answer by robertbu
http://answers.unity.com/answers/730798/view.html
@MikeNewall's solution is the traditional way to use Lerp(). Here is a common non-traditional use of Lerp() that produces an eased movement:
Vector3 des;
void Start () {
des = new Vector3(transform.position.x, 10.0F, transform.position.z);
}
void Update() {
transform.position = Vector3.Lerp(transform.position, des, speed * Time.deltaTime);
}
And here is a movement by speed that does not use a timer:
Vector3 des;
void Start () {
des = new Vector3(transform.position.x, 10.0F, transform.position.z);
}
void Update() {
transform.position = Vector3.MoveTowards(transform.position, des, speed * Time.deltaTime);
}Thu, 19 Jun 2014 15:23:25 GMTrobertbuAnswer by MikeNewall
http://answers.unity.com/answers/730781/view.html
The lerp method gives you a point that is a fraction of the way along a line between the start and end point. The fraction is supplied as the third parameter. If the fraction is 0 then the position is at the start of the line between the twho points, and a fraction of 1 would be at the end of the line. In your case it's always the same so the position never changes. You need to increase the fraction over time.
public float speed = .5f;
private Vector3 start;
private Vector3 des;
private float fraction = 0;
void Start () {
start = new Vector3(transform.position.x, transform.position.y, transform.position.z);
des = new Vector3(transform.position.x, 10f, transform.position.z);
}
void Update(){
if (fraction < 1) {
fraction += Time.deltaTime * speed;
transform.position = Vector3.Lerp(start, des, fraction);
}
}Thu, 19 Jun 2014 15:01:23 GMTMikeNewall