The Vector3.Reflect
method calculates the reflection of a vector off a surface with a specified normal. This is useful in physics simulations, graphics, and other applications where reflection behavior is needed.
The Vector3.Reflect
method calculates the reflection of a vector off a surface with a specified normal. This is useful in physics simulations, graphics, and other applications where reflection behavior is needed.
To use the Reflect
method, provide the direction vector that you want to reflect and the normal vector of the surface off which the reflection occurs. Both vectors should be passed by reference using the ref
keyword.
The method returns a new Vector3
that represents the reflected vector.
// Example of using Vector3.Reflect Vector3 direction = new Vector3(1, -1, 0); Vector3 normal = new Vector3(0, 1, 0); Vector3 reflectedVector = Vector3.Reflect(ref direction, ref normal); // reflectedVector should now be (1, 1, 0)