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

Midpoint#

Math / Midpoint

  • Can Read

  • Cannot Write

Description#

The position exactly halfway between two other positions

Parameters#

Name Description
Position 1 The position at one end
Position 2 The position at the other end

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Midpoint")]
    [Category("Math/Midpoint")]

    [Description("The position exactly halfway between two other positions")]
    [Image(typeof(IconAnchor), ColorTheme.Type.Yellow)]

    [Parameter("Position 1", "The position at one end")]
    [Parameter("Position 2", "The position at the other end")]

    [Keywords("Vector", "Middle", "Center", "Average", "Between", "Half")]

    [Serializable]
    public class TypeVector3MathMidpoint : TypeVector3
    {
        [SerializeField] private GetVector3 m_Position1 = new GetVector3();
        [SerializeField] private GetVector3 m_Position2 = new GetVector3();

        public override Vector3 GetPreview(GameObject source)
        {
            return (this.m_Position1.GetPreview(source) + this.m_Position2.GetPreview(source)) * 0.5f;
        }

        public override Vector3 Get(Args args)
        {
            return (this.m_Position1.Get(args) + this.m_Position2.Get(args)) * 0.5f;
        }

        public override string ToString()
        {
            return $"Midpoint ({this.m_Position1}, {this.m_Position2})";
        }

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