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

Reflect Direction#

Math / Reflect Direction

  • Can Read

  • Cannot Write

Description#

Reflects a direction onto a surface defined by a normal direction

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Reflect Direction")]
    [Category("Math/Reflect Direction")]
    [Description("Reflects a direction onto a surface defined by a normal direction")]
    
    [Image(typeof(IconReflect), ColorTheme.Type.Yellow)]
    [Keywords("Vector", "Bounce")]
    
    [Serializable]
    public class TypeVector2MathReflectDirection : TypeVector2
    {
        [SerializeField] private GetVector2 m_InDirection = new GetVector2();
        [SerializeField] private GetVector2 m_InNormal = new GetVector2();

        public override Vector2 GetPreview(GameObject source) =>
            Vector2.Reflect(
                this.m_InDirection.GetPreview(source),
                this.m_InNormal.GetPreview(source)
            );

        public override Vector2 Get(Args args)
        {
            return Vector2.Reflect(
                this.m_InDirection.Get(args),
                this.m_InNormal.Get(args)
            );
        }
        
        public override string ToString()
        {
            return $"Reflect {this.m_InDirection} on {this.m_InNormal}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.