Hi there.
Ok, so the answer is in here: Oscilating variable
None of the Vector3.Lerp, SmoothDamp and pingPong solved my problems.
I have a simple question about lerp. I tried to make my gameobjects float(from transform.position.y to transform.positiony-1 and back again), but cant get it to work using unty’s reference code from the Vector3.lerp page. In my scene i have some instantiated cubes, theat i want to float to transform.position.y -1, but it just goes to -infinite on y axis. To fix that i tried to declare a new Vector3 of this object in the Start function. Problem with this is that objects with this script are jumping rapidly in one position. Why is that?
I think i overlooked something very basic here, or im trying to do this with wrong kind of code.
My code(basically the reference code):
var start: Vector3;
var end: Vector3;
function Start () {
start = transform.position;
end =Vector3(transform.position.x,transform.position.y-10,transform.position.z);
}
function Update () {
var distanceTo = start - end;
var smooth = 1.0;
transform.position = Vector3.Lerp(start,end, Time.deltaTime* smooth);
}