I am new to Unity, so I am learning how to use some of its basic functions. I use C#, and notice there are two ways of making an object move, using both the commands in the title. What exactly are difference is? The way you write them seem similar/same:
onject.position = Vector3.MoveTowards(start.position, end.position, time);
onject.position = Vector3.Lerp(start.position, end.position, time);
All I know is that one seems to be smoother? If anyone can answer in simple terms so I can understand it better, thank you so much!
Take a look at the API docs for questions like this.
MoveTowards
Lerp
The last parameter int Lerp is basically a percentage: "give me a point that is ‘time’ percent closer to ‘end’, starting from point ‘start’ "
(by the way, using ‘time’, e.g. Time.deltaTime as the parameter is a common mistake when using Lerp. It can be done to get a nice “easing out” effect, but you have to understand that if you never call Lerp with the last parameter as ‘1’ ( meaning 100% ), the position will never get to the ‘end’ value )
The last parameter in MoveTowards is the max distance to move: "give me a point that is at most ‘time’ units closer to ‘end’, starting from ‘start’ "