Vector3
Variables
down
Vector3.down
Returns a Vector3 with value 0,-1,0
Example
Vector3.down
up
Vector3.up
Returns a Vector3 with value 0,1,0
Example
Vector3.up
zero
Vector3.zero
Returns a Vector3 with value 0,0,0
Example
Vector3.zero
one
Vector3.one
Returns a Vector3 with value 1,1,1
Example
Vector3.one
Functions
New
function Vector3.New((float)x , (float)y, (float)z)
Parameter | Type | Description |
---|---|---|
x | float |
X value of the new Vector3 |
y | float |
Y value of the new Vector3 |
z | float |
Z value of the new Vector3 |
Vector3.New
Creates and returns a new Vector3 with the desired x, y and z
Example
NewVector = Vector3.New(1,1,1)
StringToVector3
function Vector3.StringToVector3((string)Stringified Vector)
Parameter | Type | Description |
---|---|---|
Stringified Vector | string |
Vector3 in string form |
Vector3.StringToVector3
Turns a comma separated string into a vector3
Example
NewVector = Vector3.StringToVector3("1,1,1")
Vector3ToString
function Vector3.Vector3ToString((Vector3)Vector3)
Parameter | Type | Description |
---|---|---|
Vector3 | Vector3 |
Vector3 to turn into string |
Vector3.Vector3ToString
Turns a Vector3 into a comma separated string
Example
NewVectorString = Vector3.Vector3ToString(VectorToTurn)
DirFrom
function Vector3.DirFrom((Vector3)Vector a , (Vector3)Vector b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Origin of the direction |
Vector b | Vector3 |
Destination of the direction |
Vector3.DirFrom
Returns a Vector3 representing the direction from Vector a to Vector b normalized
Example
NewVectorString = Vector3.Vector3ToString(VectorToTurn)
Add
function Vector3.Add((Vector3)Vector a , (Vector3)Vector b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to add |
Vector b | Vector3 |
Vector3 to add |
Vector3.Add
Returns the addition of Vector3 a to Vector b
Example
NewVector = Vector3.Add(VectorA,VectorB)
Subtract
function Vector3.Subtract((Vector3)Vector a , (Vector3)Vector b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to subtract from |
Vector b | Vector3 |
Vector3 to be subtracted |
Vector3.Subtract
Returns the subtraction of Vector3 a to Vector b
Example
NewVector = Vector3.Subtract(VectorA,VectorB)
Multiply
function Vector3.Multiply((Vector3)Vector a , (Vector3)Vector b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to be multiplied |
Vector b | Vector3 |
Vector3 to multiply with |
Vector3.Multiply
Returns a new Vector3 with each component of the second multiplied the corresponding component of the first.
Example
NewVector = Vector3.Multiply(VectorA,VectorB)
Divide
function Vector3.Divide((Vector3)Vector a , (Vector3)Vector b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to be divided |
Vector b | Vector3 |
Vector3 to divided with |
Vector3.Divide
Returns a new Vector3 with each component of the second divided the corresponding component of the first.
Example
NewVector = Vector3.Divide(VectorA,VectorB)
MultiplyNumber
function Vector3.MultiplyNumber((Vector3)Vector a , (float)Number b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to be multiplied |
Number b | float |
Number to multiply with |
Vector3.MultiplyNumber
Returns a new Vector3 with each component multiplied by a number.
Example
NewVector = Vector3.MultiplyNumber(VectorA,5)
DivideNumber
function Vector3.DivideNumber((Vector3)Vector a , (float)Number b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to be divided |
Number b | float |
Number to divide with |
Vector3.DivideNumber
Returns a new Vector3 with each component divided by a number.
Example
NewVector = Vector3.DivideNumber(VectorA,5)
Distance
function Vector3.Distance((Vector3)Vector a , (Vector3)Vector b)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to find distance |
Vector b | Vector3 |
Vector3 to find distance |
Vector3.Distance
Returns a float with the distance between 2 Vector3s.
Example
Distance = Vector3.Distance(VectorA,VectorB)
Magnitude
function Vector3.Magnitude((Vector3)Vector a)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to find magnitude |
Vector3.Magnitude
Returns the magnitude of a Vector3.
Example
Vector3.Magnitude(VectorA)
sqrMagnitude
function Vector3.sqrMagnitude((Vector3)Vector a)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to find sqrMagnitude |
Vector3.sqrMagnitude
Returns the sqrMagnitude of a Vector3.
Example
Vector3.sqrMagnitude(VectorA)
Normalize
function Vector3.Normalize((Vector3)Vector a)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to normalize |
Vector3.Normalize
Returns a Vector3 with the magnitude of 1.
Example
Vector3.Normalize(VectorA)
FindSpatialHash
function Vector3.FindSpatialHash((Vector3)Vector a , (float)Cell size, (optional bool)Use Y value)
Parameter | Type | Description |
---|---|---|
Vector a | Vector3 |
Vector3 to use |
Cell size | float |
Cell size to use. |
Use Y value | optional bool |
True to use the y value, false to ignore it. It is true by default. |
Vector3.FindSpatialHash
Returns a int number generated based on this vector 3 with the desired cell size. With a cell-size small enough can be useful to generate a position based id.
Example
Vector3.Normalize(VectorA)