Endstar LUA API Documentation
Loading...
Searching...
No Matches
Vector3 Class Reference

A utility class for generating Vector3s! A Vector3 is three floats together. Often used for position or rotation. Try using this with Visuals.SetLocalRotation! More...

Public Member Functions

UnityEngine.Vector3 Create (float x, float y, float z)
 Creates a Vector3 containing the specified X, Y, and Z components.
 
UnityEngine.Vector3 Add (UnityEngine.Vector3 lhs, UnityEngine.Vector3 rhs)
 Given two vectors, adds them together component wise and returns the resulting vector. IE: new Vector3(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z)
 
UnityEngine.Vector3 Scale (UnityEngine.Vector3 vector, float scalar)
 Given a vector and a scalar float, multiplies the vector components by the float and returns the scaled vector.
 
UnityEngine.Vector3 Lerp (UnityEngine.Vector3 a, UnityEngine.Vector3 b, float t)
 Linearly interpolates from A, to B, based on a 0..1 percentage (t)
 
UnityEngine.Vector3 Cross (UnityEngine.Vector3 lhs, UnityEngine.Vector3 rhs)
 Returns the cross product vector of LHS and RHS. The cross product is always perpendicular to the LHS and RHS. Ordering of LHS and RHS matter, and flipping the values will yield a different cross product.
 
float Dot (UnityEngine.Vector3 lhs, UnityEngine.Vector3 rhs)
 Returns the dot product of LHS and RHS. When LHS and RHS are normalized the dot product indicates how aligned the two vectors are, with -1 being opposite parallel, 0 being perpendicular, and 1 being aligned parallel.
 
UnityEngine.Vector3 Normalize (UnityEngine.Vector3 vec)
 Takes a vector and normalizes so that the vector has a magnitude of 1, and neither the X, Y, or Z components will exceed one. Normalizing a vector is very useful, especially when comparing dot products to see how aligned two vectors are for gameplay purposes.
 
UnityEngine.Vector3 Reflect (UnityEngine.Vector3 inDirection, UnityEngine.Vector3 inNormal)
 Takes a directional vector and a normal, and returns a vector that is the mirror reflection of the direction vector.
 
UnityEngine.Vector3 Scale (UnityEngine.Vector3 a, UnityEngine.Vector3 b)
 Multiplies the components of two vectors, ie: a.x * b.x, a.y * b.y, a.z * b.z. Returns a vector with those multiplied components in their respective component.
 
UnityEngine.Vector3 MoveTowards (UnityEngine.Vector3 current, UnityEngine.Vector3 target, float maxDistanceDelta)
 Similar to lerp, given Current and Target vectors, will move current towards target by up to maxDistanceDelta. Unlike lerp, the two vectors are not absolute origin or end points and maxDistanceDelta is not expected to be between 0 and 1.
 
UnityEngine.Vector3 Project (UnityEngine.Vector3 vector, UnityEngine.Vector3 onNormal)
 Given a Vector and a Normal, returns a vector that represents how much of the vector is aligned with the normal, along the normal.
 
UnityEngine.Vector3 RotateTowardsDegrees (UnityEngine.Vector3 current, UnityEngine.Vector3 target, float maxDegreesDelta, float maxMagnitudeDelta)
 Given a current and target vector, rotates current to align with target with controls for the maximum degree rotation and maximum change in vector size. Operates on Degrees, not Radians.
 
UnityEngine.Vector3 RotateTowardsRadians (UnityEngine.Vector3 current, UnityEngine.Vector3 target, float maxRadiansDelta, float maxMagnitudeDelta)
 Given a current and target vector, rotates current to align with target with controls for the maximum radian rotation and maximum change in vector size. Operates on Radians, not Degrees.
 
float Angle (UnityEngine.Vector3 from, UnityEngine.Vector3 to)
 Determines the unsigned angle between two vectors. This angle will never be negative, for negative angles see SignedAngle
 
float SignedAngle (UnityEngine.Vector3 from, UnityEngine.Vector3 to, UnityEngine.Vector3 axis)
 Determines the signed angle between two vectors.
 
float Distance (UnityEngine.Vector3 a, UnityEngine.Vector3 b)
 Given two vectors representing points, returns the distance between those two points.
 
float Magnitude (UnityEngine.Vector3 vector)
 Returns the length of the vector. Performs costly square root operations, for length based operations that don't need precise measurements but relative measurements, SqrMagnitude
 
float SqrMagnitude (UnityEngine.Vector3 vector)
 Returns the squared length of the vector. Useful when you want to compare relative sizes (which point is closer between A -> B and A -> C,without concern for specific distance). For getting the specific exact distance, Magnitude
 
UnityEngine.Vector3 Min (UnityEngine.Vector3 lhs, UnityEngine.Vector3 rhs)
 Returns a Vector composed of the smallest components between LHS and RHS.
 
UnityEngine.Vector3 Max (UnityEngine.Vector3 lhs, UnityEngine.Vector3 rhs)
 Returns a Vector composed of the largest components between LHS and RHS.
 

Detailed Description

A utility class for generating Vector3s! A Vector3 is three floats together. Often used for position or rotation. Try using this with Visuals.SetLocalRotation!

Member Function Documentation

◆ Add()

UnityEngine.Vector3 Add ( UnityEngine.Vector3 lhs,
UnityEngine.Vector3 rhs )

Given two vectors, adds them together component wise and returns the resulting vector. IE: new Vector3(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z)

Parameters
lhs
rhs
Returns

◆ Angle()

float Angle ( UnityEngine.Vector3 from,
UnityEngine.Vector3 to )

Determines the unsigned angle between two vectors. This angle will never be negative, for negative angles see SignedAngle

Parameters
from
to
Returns

◆ Create()

UnityEngine.Vector3 Create ( float x,
float y,
float z )

Creates a Vector3 containing the specified X, Y, and Z components.

Parameters
x
y
z
Returns

◆ Cross()

UnityEngine.Vector3 Cross ( UnityEngine.Vector3 lhs,
UnityEngine.Vector3 rhs )

Returns the cross product vector of LHS and RHS. The cross product is always perpendicular to the LHS and RHS. Ordering of LHS and RHS matter, and flipping the values will yield a different cross product.

Parameters
lhs
rhs
Returns

◆ Distance()

float Distance ( UnityEngine.Vector3 a,
UnityEngine.Vector3 b )

Given two vectors representing points, returns the distance between those two points.

Parameters
a
b
Returns

◆ Dot()

float Dot ( UnityEngine.Vector3 lhs,
UnityEngine.Vector3 rhs )

Returns the dot product of LHS and RHS. When LHS and RHS are normalized the dot product indicates how aligned the two vectors are, with -1 being opposite parallel, 0 being perpendicular, and 1 being aligned parallel.

Parameters
lhs
rhs
Returns

◆ Lerp()

UnityEngine.Vector3 Lerp ( UnityEngine.Vector3 a,
UnityEngine.Vector3 b,
float t )

Linearly interpolates from A, to B, based on a 0..1 percentage (t)

Parameters
aThe 0 value of t
bThe 1 value of t
tHow far between A and B. This value is expected to be between 0 and 1, with 0 returning A, 1 returning B, and values in between returning a value between A and B.
Returns

◆ Magnitude()

float Magnitude ( UnityEngine.Vector3 vector)

Returns the length of the vector. Performs costly square root operations, for length based operations that don't need precise measurements but relative measurements, SqrMagnitude

Parameters
vector
Returns

◆ Max()

UnityEngine.Vector3 Max ( UnityEngine.Vector3 lhs,
UnityEngine.Vector3 rhs )

Returns a Vector composed of the largest components between LHS and RHS.

Parameters
lhs
rhs
Returns

◆ Min()

UnityEngine.Vector3 Min ( UnityEngine.Vector3 lhs,
UnityEngine.Vector3 rhs )

Returns a Vector composed of the smallest components between LHS and RHS.

Parameters
lhs
rhs
Returns

◆ MoveTowards()

UnityEngine.Vector3 MoveTowards ( UnityEngine.Vector3 current,
UnityEngine.Vector3 target,
float maxDistanceDelta )

Similar to lerp, given Current and Target vectors, will move current towards target by up to maxDistanceDelta. Unlike lerp, the two vectors are not absolute origin or end points and maxDistanceDelta is not expected to be between 0 and 1.

Parameters
current
target
maxDistanceDelta
Returns

◆ Normalize()

UnityEngine.Vector3 Normalize ( UnityEngine.Vector3 vec)

Takes a vector and normalizes so that the vector has a magnitude of 1, and neither the X, Y, or Z components will exceed one. Normalizing a vector is very useful, especially when comparing dot products to see how aligned two vectors are for gameplay purposes.

Parameters
vec
Returns

◆ Project()

UnityEngine.Vector3 Project ( UnityEngine.Vector3 vector,
UnityEngine.Vector3 onNormal )

Given a Vector and a Normal, returns a vector that represents how much of the vector is aligned with the normal, along the normal.

Parameters
vector
onNormal
Returns

◆ Reflect()

UnityEngine.Vector3 Reflect ( UnityEngine.Vector3 inDirection,
UnityEngine.Vector3 inNormal )

Takes a directional vector and a normal, and returns a vector that is the mirror reflection of the direction vector.

Parameters
inDirection
inNormal
Returns

◆ RotateTowardsDegrees()

UnityEngine.Vector3 RotateTowardsDegrees ( UnityEngine.Vector3 current,
UnityEngine.Vector3 target,
float maxDegreesDelta,
float maxMagnitudeDelta )

Given a current and target vector, rotates current to align with target with controls for the maximum degree rotation and maximum change in vector size. Operates on Degrees, not Radians.

Parameters
current
target
maxDegreesDelta
maxMagnitudeDelta
Returns

◆ RotateTowardsRadians()

UnityEngine.Vector3 RotateTowardsRadians ( UnityEngine.Vector3 current,
UnityEngine.Vector3 target,
float maxRadiansDelta,
float maxMagnitudeDelta )

Given a current and target vector, rotates current to align with target with controls for the maximum radian rotation and maximum change in vector size. Operates on Radians, not Degrees.

Parameters
current
target
maxRadiansDelta
maxMagnitudeDelta
Returns

◆ Scale() [1/2]

UnityEngine.Vector3 Scale ( UnityEngine.Vector3 a,
UnityEngine.Vector3 b )

Multiplies the components of two vectors, ie: a.x * b.x, a.y * b.y, a.z * b.z. Returns a vector with those multiplied components in their respective component.

Parameters
a
b
Returns

◆ Scale() [2/2]

UnityEngine.Vector3 Scale ( UnityEngine.Vector3 vector,
float scalar )

Given a vector and a scalar float, multiplies the vector components by the float and returns the scaled vector.

Parameters
vector
scalar
Returns

◆ SignedAngle()

float SignedAngle ( UnityEngine.Vector3 from,
UnityEngine.Vector3 to,
UnityEngine.Vector3 axis )

Determines the signed angle between two vectors.

Parameters
from
to
axis
Returns

◆ SqrMagnitude()

float SqrMagnitude ( UnityEngine.Vector3 vector)

Returns the squared length of the vector. Useful when you want to compare relative sizes (which point is closer between A -> B and A -> C,without concern for specific distance). For getting the specific exact distance, Magnitude

Parameters
vector
Returns