Mathf Lerp not working, Need to change value smoothly

Hello people
I want to ask you how to use Mathf.Lerp.
I need to create a gui animation, A gui button moves from one rect, to another smoothly.
I have tried with Mathf Lerp:
var a : Rect;
var b : Rect;
var multiplier : float; // tried all these multipliers {0.01, 1, 10, 100, 1000}
a.x = Mathf.Lerp (a.x, b.x, Time.deltaTime*multiplier);
But with 10 multiplier per example it moves the gui object of 10 percent. And also it does not move the gui, it change the position and in one frame the gui is moved.
But with 100 multiplier.
I have tried also with timer, which adds Time deltaTime multiplicated to a multiplier, as here: How the heck does Mathf.Lerp work? - Questions & Answers - Unity Discussions
I have tried also with:
a.x = (b.x - a.x) * Time.deltaTime * time;
but it move my gui of only the time value, and also only change the position, does not translate it.
What I have to use, please help, thanks, have a nice day!

To get a smooth movement using Lerp divide the speed by the distance between the two points.

var distance : float;

distance = a.x - b.x;
if(distance <0){
distance = distance * -1;
}
a.x = Mathf.Lerp (a.x, b.x, Time.deltaTime*(multiplier/distance));

Just FYI if you want it to move on the X or Y planes you could just use distance = Vector2.Distance(a, b);

I tried, but It didn’t worked, It did the same think as the first sources. Time.deltaTime is a value which increments from 0 to 1 right? So why it doesn’t give me a smooth value which starts from first value and ends to second value, smoothly?

No, it’s just the time since the last frame. If it’s ever 1 that means you’re getting 1 frame per second; ideally it should always be something less than .02. You’d want to use a coroutine such as this.

–Eric

No, it is not 1, it is alway under 0.02, I have put a GUILayout.Label which show me the value of Time.deltaTime, and is always: 0.01656 _ _ _ _ (the value written _ changes, but 0.01656 is costant.
So I read the description of Time.deltaTime: Unity - Scripting API: Time.deltaTime
and there is written:

then I tried with:
var val : String;
function Update () {val = Time.deltaTime.ToString();}
function OnGUI () {GUILayout.Label (val);}
But got the same problem. The value is costantly 0.01656

That’s not a problem. As I said, Time.deltaTime is the time since the last frame. If it’s always .0166 then your monitor has a 60Hz refresh rate and you have vsync on (and nothing intensive is going on to reduce the framerate below 60).

–Eric

I resolved, this was caused because it was in a script which was called one time in determinated condition which will delete instatly, Now I put the condition in update, and this condition won’t delete untill animation is finished, thanks, guys. Have a nice day

Click on the link I provided with my first post in this thread.

–Eric

or place an animation to gameObject that has the gui. the gui moves 1 pixel per 0.01 units in inspector