Hiya,
I have a start position and an end position and what I would like to do is to have a GO rotate to a point but I would like it to ease to that point versus a LookAt. I was thinking I could do this with Lerp and this is sort of what I have:
private var target : GameObject;
private var moveToVect : Vector3;
private var toDo : boolean;
function open ( go : GameObject ) {
target = go;
moveToVect = Vector3(target.transform.position.x, 0, target.transform.position.z);
toDo = true;
}
function Update () {
if (toDo){
var t : Vector3 = Vector3.Lerp(gameObject.transform.position, moveToVect, Time.time/30);
// Look at the target
transform.LookAt(t);
}
}
I am getting the turn I want but it is more springy and immediate. I have tried all kinds of different values for the “t” but there seems to be no difference.
Any ideas?
Thanks,
– Clint
As you probably know, lerp is just one very simple function:
now = start * (1-t) + end * t
… and often one wants similar but different curves.
Jonathan (and Neil and others) have made a group of functions that provide various Lerp-like curves. Check them out for use or inspiration:
http://www.unifycommunity.com/wiki/index.php?title=Mathfx
d.
Thanks David!
I’ll have a look and see if any of them are what I am looking for.
Regards,
– Clint
I think your main problem is the use of Time.time. This records absolute time from the start of the current scene, so the longer time passes, the faster it will animate. Try using Time.deltaTime instead, then you’ll be fine
Hi Nicholas!
I tried Time.deltaTime as well and all sorts of various configurations… But the same result for all of them… 
Can I not do something like that and apply it to a LookAt?
Thanks,
– Clint
If you want a turn that “springs” the instant it’s started, and then more slowly settles on the object in question, You can use a form I use a lot:
position = Vector3.Lerp(position, newPosition, Time.deltaTime);
It seems useless, but when you repeat it, it gradually moves the old value to the new one - with a nice “snap” at the beginning.
var target : Transform;
var lookHere : Vector3;
function open(go : GameObject) {
target = go.transform;
}
function Update() {
if (target) lookHere = Vector3.Lerp(lookHere, target.position, Time.deltaTime);
transform.LookAt(lookHere);
}
Hiya,
It just isn’t working for me. 
I currently have that snap type effect with LookAt… What I am looking for is more of a smooth rotate. I tried getting the angle but that was giving a positive number and I need to rotate in a negative space as well (left or right depending on where the item I am turning to is).
Thanks for the help!
– Clint
If you need the angle, use the form: Mathf.Atan2(pos1.x, pos1.z) - Mathf.Atan2(pos2.x, pos2.z) It’s like Angle, but only works in 2D space and gives you the angle between them with proper signage. If you only need it to work in 2D, great!
If you need smoothing on both the entry and exit of the interpolation curve, there’s a function in Mathfx.cs that does that.
Thanks StarManta!
I’ll look into those! I actually never even thought about using a 2D alogorithm but that may work. I saw the Mathfx library a while back but never actually looked to see what was in there, it’s probably about time I did! 
Appreciate the help!
Regards,
– Clint
Have you tried using the builtin Smooth Lookat script in the standard assets. Or adapting the code that you can find there?
DOH! Sure haven’t. I will absolutely take a look at it…
Thanks Jo!
– Clint