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

Dot Product#

Math / Geometry / Dot Product Vector3

  • Can Read

  • Cannot Write

Description#

Returns a value between 1 and -1 depending on how similar two directions are

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Dot Product")]
    [Category("Math/Geometry/Dot Product", "Vector3")]
    [Description("Returns a value between 1 and -1 depending on how similar two directions are")]
    
    [Image(typeof(IconMultiplyCircle), ColorTheme.Type.Yellow)]
    [Keywords("Vector", "Direction")]
    
    [Serializable]
    public class TypeNumberMathVector3Dot : TypeNumber
    {
        [SerializeField] private GetVector3 m_Vector1 = new GetVector3();
        [SerializeField] private GetVector3 m_Vector2 = new GetVector3();

        public override double GetPreview(GameObject source) =>
            Vector3.Dot(
                this.m_Vector1.GetPreview(source),
                this.m_Vector2.GetPreview(source)
            );

        public override double Get(Args args)
        {
            return Vector3.Dot(
                this.m_Vector1.Get(args),
                this.m_Vector2.Get(args)
            );
        }
        
        public override string ToString()
        {
            return $"{this.m_Vector1} * {this.m_Vector2}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.