I have a cube, on a simple plane…
The cube is at position 5.6.7.
i have an update function in javascript.
What is the easiest way to move the cube to position 2,3,9 over a period of 2 seconds?
I have a cube, on a simple plane…
The cube is at position 5.6.7.
i have an update function in javascript.
What is the easiest way to move the cube to position 2,3,9 over a period of 2 seconds?
var time =0.0;
function Update() {
time += Time.deltaTime;
transform.position = Vector3.Lerp(transform.position, Vector3(2,3,9), time / 2);
}
You would need to reset time to 0 if you move the object and wanted the movement to happen again.
From the documentation:
function Update () {
transform.position = Vector3.Lerp(start.position, end.position, Time.time);
}