Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Interpolate Angle#

Math / Algebra / Interpolate Angle

  • Can Read

  • Cannot Write

Description#

Interpolates a value between A and B given a ratio number wrapped around 360

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Interpolate Angle")]
    [Category("Math/Algebra/Interpolate Angle")]
    
    [Description("Interpolates a value between A and B given a ratio number wrapped around 360")]
    [Image(typeof(IconInterpolate), ColorTheme.Type.Yellow, typeof(BadgeAlpha))]
    
    [Keywords("Lerp", "Slerp", "Linear", "Smooth", "Damp", "Angle", "Degrees", "Step")]
    
    [Serializable]
    public class TypeNumberMathInterpolateAngle : TypeNumber
    {
        [SerializeField] private GetNumber m_AngleA = new GetNumber();
        [SerializeField] private GetNumber m_AngleB = new GetNumber();
        
        [SerializeField] private GetNumber m_Ratio = new GetNumber();
        [SerializeField] private EaseMode m_Easing = EaseMode.Linear;

        public override double GetPreview(GameObject source)
        {
            float ratio = Ease.Get(this.m_Easing, (float) this.m_Ratio.GetPreview(source));
            return Interpolate(this.m_AngleA.GetPreview(source), this.m_AngleB.GetPreview(source), ratio);
        }

        public override double Get(Args args)
        {
            double a = this.m_AngleA.Get(args);
            double b = this.m_AngleB.Get(args);
            
            double ratio = Ease.Get(this.m_Easing, (float) this.m_Ratio.Get(args));
            return Interpolate(a, b, ratio);
        }

        private static double Interpolate(double a, double b, double ratio)
        {
            return Mathf.LerpAngle((float) a, (float) b, (float) ratio);
        }

        public override string ToString()
        {
            return $"Interpolate {this.m_AngleA} to {this.m_AngleB} by {this.m_Ratio}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.