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 TypeVector3MathReflectDirection : TypeVector3
{
[SerializeField] private GetVector3 m_InDirection = new GetVector3();
[SerializeField] private GetVector3 m_InNormal = new GetVector3();
public override Vector3 GetPreview(GameObject source) =>
Vector3.Reflect(
this.m_InDirection.GetPreview(source),
this.m_InNormal.GetPreview(source)
);
public override Vector3 Get(Args args)
{
return Vector3.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;
}
}