# For the noobs: Lerp tutorial (point a to b animation)

Hello, Unity forums. Recently, I have been posting a lot of crap, so, I need to shape up and contribute. Now, if you are a long time user of Unity, this will probably be of no use to you. Sorry for any grammar mistakes, as for it is midnight here, and I am tired.

Lerp
A tutorial by CreativeCoding (Sean Grant)

What it does:
Well, in the documentation, lerp “Linearly interpolates between two vectors.” Well. What does this mean? My basic understanding is that it gives coordinates every update for the object to move to.

How to use it:

``````//This declares our target, aka: point b
var target : Transform;
//This is our speed. It is SUPER sensitive, so its best to use a float
var speed : float = 0.5;
//Start the update function
function Update(){
//Here's where the magic happens. Lerp is actually giving coordinates for the new position every update.
transform.position = Vector3.Lerp(transform.position, target.position, speed);
}
``````

I hope I helped some noobs out there. This is the piece of code that got me started in the first place.

Unfortunately this is not correct. You’re setting the position to be a given point between the transform.position and target.position every frame, which makes it framerate-dependent. For some discussion of using lerp properly, see here.

No, not really. Linearly interpolating between two vectors means just that. If you use .5 for the third parameter, then lerp returns a point halfway between the two supplied points. If you use .25, then it returns a point 25% of the way between point A and point B. If you use .75, then it returns a point 75% of the way between point A and point B. If you use 0, then it returns point A; if you use 1, then it returns point B.

So, any values between 0 and 1 return a given percentage between the two points. That is linear (a straight line) interpolation (getting a new value from existing known values).

–Eric

1 Like

You should not use word “noob” becouse its rude use word newbie. Noob is a person that don’t know how to do one thing and its ignoring ( or being rude to ) people that want to help him by teaching for example. Newbie is someone new and don’t have enough skills.

So i am newbie beocsue i don’t have any skills in scripting but i am thanking everyone that helps me.
If i was rude to people that want to help me by saying bad stuff or trolling on them i would be a “noob”

Hmm… isn’t supposed that transform is using its pivot to declare a vector3 position ?..

I was using transform to position intervals… and works fine, the only thing to take in mind is to have the target object’s pivot centered to its object…

well at least there are many ways to do…

Noob is a term for New, just as newbie is. It has the same meaning. You are adding personal opinion onto the definition. New, in any form, means to not know, and learning doesn’t always apply because the individual doesn’t always want to learn. It is in the context to imply if a word is rude; not the definition.

Actually , some old school internet etiquette , would show that hes correct , originally , Newb was used , until gamers around the world took on the term noob and have similated it to mean the same , but in reality it never did mean the same thing.

This IS indeed the origins, and way that it was (and in MO still is) but the common general public seems to have merged this all into one unglorified term.

Is it possible to have a lerp outside an Update. e.g. if i need the lerp to occur inside another function like LerpMe();

You can Lerp anywhere, it’s just a function that returns a value like any other function. It’s likely that you wouldn’t use it in Update anyway.

–Eric

I believe the original poster explained Lerp in this fashion because that is how the Unity tutorials does. However after reading the comments I am confused by the definition of Lerp and how it was implemented in the tutorial. The developers added a smoothing variable as the 3rd parameter in order to control the movement speed. But how does this factor into obtaining a position between to points? Does is mean that is just calculates the position at this speed or at this fixed point?