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#

Math / Move Towards

  • Can Read

  • Cannot Write

Description#

Moves from one position to another, but no farther than a delta distance

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Move Towards")]
    [Category("Math/Move Towards")]
    [Description("Moves from one position to another, but no farther than a delta distance")]
    
    [Image(typeof(IconPosition), ColorTheme.Type.Yellow, typeof(BadgeArrowRight))]
    [Keywords("Vector", "Translate")]
    
    [Serializable]
    public class TypeVector2MathMoveTowards : TypeVector2
    {
        [SerializeField] private GetVector2 m_Current = new GetVector2();
        
        [SerializeField] private GetVector2 m_Target = new GetVector2();
        
        [SerializeField] private GetNumber m_MaxDistanceDelta = new GetNumber();
        
        public override Vector2 Get(Args args)
        {
            return Vector2.MoveTowards(
                this.m_Current.Get(args),
                this.m_Target.Get(args),
                (float) this.m_MaxDistanceDelta.Get(args)
            );
        }
        
        public override string ToString()
        {
            return $"Move from {this.m_Current} towards {this.m_Target}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.