lerping unity code example
Example 1: vector3.lerp
Vector3.Lerp(startMarker.position, endMarker.position, fractionOfJourney);
Example 2: unity lerp
thisText.color = Color.Lerp(normalColour, noAlpha, (Time.time - startTime) / lifeTime);
Example 3: unity lerp
using UnityEngine;
using System.Collections;public class ExampleClass : MonoBehaviour
{
public Transform startMarker;
public Transform endMarker;
public float speed = 1.0F;
private float startTime;
private float journeyLength; void Start()
{
startTime = Time.time;
journeyLength = Vector3.Distance(startMarker.position, endMarker.position);
}
void Update()
{
float distCovered = (Time.time - startTime) * speed;
float fractionOfJourney = distCovered / journeyLength;
transform.position = Vector3.Lerp(startMarker.position, endMarker.position, fractionOfJourney);
}
}