Curved A to B Vector3.Lerp?

When you write “curved”, do you mean “non-linear interpolation” ? Y/N

If the answer is yes:

InOutBounce GIF 22.02.2024 22-47-45

  1. Place this Easing.cs in your project
using UnityEngine;

public static class Easing
{
    public static float Linear ( float t ) => t;
    public static float InBack ( float t ) => t*t*t-t*Mathf.Sin(t*Mathf.PI);
    public static float OutBack ( float t ) => 1f-InBack(1f-t);
    public static float InOutBack ( float t ) => t<0.5f ? 0.5f*InBack(2f*t) : 0.5f*OutBack(2f*t-1f)+0.5f;
    public static float InBounce ( float t ) => 1f-OutBounce(1f-t);
    public static float OutBounce ( float t ) => t<4f/11.0f ? (121f*t*t)/16.0f : t<8f/11.0f ? (363f/40f*t*t)-(99f/10f*t)+17f/5.0f : t<9f/10f ? (4356f/361.0f*t*t)-(35442f/1805.0f*t)+16061f/1805.0f : (54f/5.0f*t*t)-(513f/25.0f*t)+268f/25.0f;
    public static float InOutBounce ( float t ) => t<0.5f ? 0.5f*InBounce(2f*t) : 0.5f*OutBounce(2f*t-1f)+0.5f;
    public static float InCirc ( float t ) => 1f-Mathf.Sqrt(1f-(t*t));
    public static float OutCirc ( float t ) => Mathf.Sqrt((2f-t)*t);
    public static float InOutCirc ( float t ) => t<0.5f ? 0.5f*(1-Mathf.Sqrt(1f-4f*(t*t))) : 0.5f*(Mathf.Sqrt(-((2f*t)-3f)*((2f*t)-1f))+1f);
    public static float InCubic ( float t ) => t*t*t;
    public static float OutCubic ( float t ) => InCubic(t-1f)+1f;
    public static float InOutCubic ( float t ) => t<0.5f ? 4f*t*t*t : 0.5f*InCubic(2f*t-2f)+1f;
    public static float InElastic ( float t ) => Mathf.Sin(13f*(Mathf.PI*0.5f)*t)*Mathf.Pow(2f, 10f*(t-1f));
    public static float OutElastic ( float t ) => Mathf.Sin(-13f*(Mathf.PI*0.5f)*(t+1))*Mathf.Pow(2f, -10f*t)+1f;
    public static float InOutElastic ( float t ) => t<0.5f ? 0.5f*Mathf.Sin(13f*(Mathf.PI*0.5f)*(2f*t))*Mathf.Pow(2f, 10f*((2f*t)-1f)) : 0.5f*(Mathf.Sin(-13f*(Mathf.PI*0.5f)*((2f*t-1f)+1f))*Mathf.Pow(2f, -10f*(2f*t-1f))+2f);
    public static float InExpo ( float t ) => Mathf.Approximately(0f,t) ? t : Mathf.Pow(2f, 10f*(t-1f));
    public static float OutExpo ( float t ) => Mathf.Approximately(1.0f, t) ? t : 1f-Mathf.Pow(2f, -10f*t);
    public static float InOutExpo ( float v ) => Mathf.Approximately(0f, v) || Mathf.Approximately(1.0f, v) ? v : v<0.5f ?  0.5f*Mathf.Pow(2f, (20f*v)-10f) : -0.5f*Mathf.Pow(2f, (-20f*v)+10f)+1f;
    public static float InQuad ( float t ) => t*t;
    public static float OutQuad ( float t ) => -t*(t-2f);
    public static float InOutQuad ( float t ) => t<0.5f ?  2f*t*t : -2f*t*t+4f*t-1f;
    public static float InQuart ( float t ) => t*t*t*t;
    public static float OutQuart ( float t ) => Mathf.Pow(t-1f,3)*(1f-t)+1f;
    public static float InOutQuart ( float t ) => t<0.5f ? 8f*InQuart(t) : -8f*InQuart(t-1f)+1f;
    public static float InQuint ( float t ) => t*t*t*t*t;
    public static float OutQuint ( float t ) => InQuint(t-1f)+1f;
    public static float InOutQuint ( float t ) => t<0.5f ? 16f*InQuint(t) : 0.5f*InQuint(2f*t-2f)+1f;
    public static float InSine ( float t ) => Mathf.Sin((t-1f)*(Mathf.PI*0.5f))+1f;
    public static float OutSine ( float t ) => Mathf.Sin(t*(Mathf.PI*0.5f));
    public static float InOutSine ( float t ) => 0.5f*(1f-Mathf.Cos(t*Mathf.PI));
}

  1. Pick a easing function from a cheat sheet:

Easing Functions Cheat Sheet

  1. Use Easing functions with Vector3.LerpUnclamped
    (“unclamped” because some functions go outside 0-1 range when lerping)
using System.Collections;
using UnityEngine;

public class EasyPeasy : MonoBehaviour
{
    [SerializeField] Transform _object;
    [SerializeField] Vector3 _a = new Vector3(0,5,0);
    [SerializeField] Vector3 _b = new Vector3(0,0,0);
    [SerializeField] float _startTime = 1f;
    [SerializeField] float _duration = 3f;
    [SerializeField] bool _repeat = true;
    IEnumerator Start ()
    {
        bool done = false;
        while( !done )
        {
            float progress = Mathf.Clamp( (Time.time-_startTime)/_duration , 0 , 1 );
            float t = Easing.OutBounce(progress);
            _object.position = Vector3.LerpUnclamped( _a , _b , t );
            if( progress>=1 )
            {
                if( _repeat ) _startTime = Time.time;
                else done = true;
            }
            yield return null;
        }
    }
}

If the answer is no:

You can create interpolation that takes a curved path by doing pretty much the same as above but interpolating Vector3 xyz components separately using Mathf.LerpUnclamped.

GIF 22.02.2024 23-11-33

using System.Collections;
using UnityEngine;

public class EasyPeasy : MonoBehaviour
{
    [SerializeField] Transform _object;
    [SerializeField] Vector3 _a = new Vector3(1,1,1);
    [SerializeField] Vector3 _b = new Vector3(3,3,3);
    [SerializeField] float _startTime = 1f;
    [SerializeField] float _duration = 3f;
    [SerializeField] bool _repeat = true;
    IEnumerator Start ()
    {
        bool done = false;
        while( !done )
        {
            float progress = Mathf.Clamp( (Time.time-_startTime)/_duration , 0 , 1 );
            _object.position = new Vector3(
                Mathf.LerpUnclamped( _a.x , _b.x , Easing.InQuint(progress) ) ,
                Mathf.LerpUnclamped( _a.y , _b.y , Easing.InOutSine(progress) ) ,
                Mathf.LerpUnclamped( _a.z , _b.z , Easing.InOutBack(progress) )
            );
            if( progress>=1 )
            {
                if( _repeat ) _startTime = Time.time;
                else done = true;
            }
            yield return null;
        }
    }
}