right using of lerp functions code example
Example 1: what is lerp function
using UnityEngine;public class Example : MonoBehaviour
{
// Interpolates rotation between the rotations
// of from and to.
// (Choose from and to not to be the same as
// the object you attach this script to) Transform from;
Transform to;
float speed = 0.1f;
void Update()
{
transform.rotation = Quaternion.Lerp(from.rotation, to.rotation, Time.time * speed);
}
}
Example 2: lerp function
//lerp takes 3 parameters
//1st parameter is the start point
//2nd is the end point
//3rd is the percentage of how much distance can be covered like .5 = 50%
//example - lerp(0,10,.5) = 5
//example2 - lerp(0,5,.2) = 1