unity lerp code example
Example 1: unity lerp position
transform.position = Vector3.Lerp(transform.position, myTargetPosition.position, speed * Time.deltaTime);
Example 2: vector3.lerp
Vector3.Lerp(startMarker.position, endMarker.position, fractionOfJourney);
Example 3: unity float lerp
Mathf.Lerp(minimum, maximum, t)
Example 4: unity lerp
thisText.color = Color.Lerp(normalColour, noAlpha, (Time.time - startTime) / lifeTime);
Example 5: 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);
}
}
Example 6: how to lerp a value in unity
lerpValue = Mathf.Lerp(minValue, maxValue, interpolationPoint);