Class: Vec3
Lua
C++
Edit

Vec3:Reflect

This function bounces the vector off a specified normal vector and returns the result.

Syntax

Parameter Description
normal surface normal to reflect off of

Returns

Returns the reflected vector.

Example

-- The motion is pointing down and forward
local motion = Vec3(0, -1, 1)

-- The ground is pointing up
local ground = Vec3(0, 1, 0)

-- Calculate bounce angle
local bounce = motion:Reflect(ground)

-- The bounce angle should be up and forward
Print(bounce.x .. ", " .. bounce.y .. ", " .. bounce.z)
Copyright © 2024 Ultra Software.
All rights reserved.