Utils_Lerp

Anonymous
csharp
06/28/2024 12:05 PM
820 B
31
Indexable
using Godot;
using System;


public class Utils
{
        public static Vector3 Lerp(Vector3 a, Vector3 b, float t)
        {
            t = Mathf.Clamp(t, 0, 1);
            return new Vector3(
                a.X + (b.X - a.X) * t,
                a.Y + (b.Y - a.Y) * t,
                a.Z + (b.Z - a.Z) * t
            );
        }

        public static Vector2 Lerp2D(Vector2 a, Vector2 b, float t)
        {
            t = Mathf.Clamp(t, 0, 1);
            return new Vector2(
                a.X + (b.X - a.X) * t,
                a.Y + (b.Y - a.Y) * t
            );
        }
}
Editor is loading...
Leave a Comment