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

Move Towards Angle#

Math / Algebra / Move Towards Angle

  • Can Read

  • Cannot Write

Description#

Moves an angle in degrees towards another one taking the shortest path around

Parameters#

Name Description
Current The angle in degrees the movement starts from
Target The angle in degrees the movement is heading to
Max Delta The largest change in degrees allowed in a single step

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Move Towards Angle")]
    [Category("Math/Algebra/Move Towards Angle")]

    [Description("Moves an angle in degrees towards another one taking the shortest path around")]
    [Image(typeof(IconProtractor), ColorTheme.Type.Yellow, typeof(BadgeSpeed))]

    [Parameter("Current", "The angle in degrees the movement starts from")]
    [Parameter("Target", "The angle in degrees the movement is heading to")]
    [Parameter("Max Delta", "The largest change in degrees allowed in a single step")]

    [Keywords("Approach", "Degrees", "Rotation", "Shortest", "Wrap", "Towards")]

    [Serializable]
    public class TypeNumberMathMoveTowardsAngle : TypeNumber
    {
        [SerializeField] private GetNumber m_Current = new GetNumber();
        [SerializeField] private GetNumber m_Target = new GetNumber();
        [SerializeField] private GetNumber m_MaxDelta = new GetNumber(1f);

        public override double GetPreview(GameObject source) => Mathf.MoveTowardsAngle(
            (float) this.m_Current.GetPreview(source),
            (float) this.m_Target.GetPreview(source),
            (float) this.m_MaxDelta.GetPreview(source)
        );

        public override double Get(Args args)
        {
            return Mathf.MoveTowardsAngle(
                this.m_Current.GetFloat(args),
                this.m_Target.GetFloat(args),
                this.m_MaxDelta.GetFloat(args)
            );
        }

        public override string ToString()
        {
            return $"{this.m_Current} towards angle {this.m_Target}";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.