Click or drag to resize

Vector3 Structure

3-element structure that can be used to represent positions in 3D space or any other pair of numeric values.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
[SerializableAttribute]
public struct Vector3 : IEquatable<Vector3>

The Vector3 type exposes the following members.

Constructors
  NameDescription
Public methodVector3(Vector3)
Constructs a new Vector3 from an existing Vector3.
Public methodVector3(Single, Single, Single)
Constructs a new Vector3 with the given components.
Top
Properties
  NameDescription
Public propertyStatic memberBack
Back unit vector. Represents the local direction of back, and the global direction of south.
Public propertyStatic memberDown
Down unit vector.
Public propertyStatic memberForward
Forward unit vector. Represents the local direction of forward, and the global direction of north.
Public propertyStatic memberInf
Infinity vector, a vector with all components set to `Mathf.Inf`.
Public propertyItem
Access vector components using their index.
Public propertyStatic memberLeft
Left unit vector. Represents the local direction of left, and the global direction of west.
Public propertyStatic memberNegOne
Deprecated, please use a negative sign with One instead.
Public propertyStatic memberOne
One vector, a vector with all components set to `1`.
Public propertyStatic memberRight
Right unit vector. Represents the local direction of right, and the global direction of east.
Public propertyStatic memberUp
Up unit vector.
Public propertyStatic memberZero
Zero vector, a vector with all components set to `0`.
Top
Methods
  NameDescription
Public methodAbs
Returns a new vector with all components in absolute values (i.e. positive).
Public methodAngleTo
Returns the minimum angle to the given vector, in radians.
Public methodBounce
Returns this vector "bounced off" from a plane defined by the given normal.
Public methodCeil
Returns a new vector with all components rounded up (towards positive infinity).
Public methodCross
Returns the cross product of this vector and `b`.
Public methodCubicInterpolate
Performs a cubic interpolation between vectors `preA`, this vector, `b`, and `postB`, by the given amount `t`.
Public methodDirectionTo
Returns the normalized vector pointing from this vector to `b`.
Public methodDistanceSquaredTo
Returns the squared distance between this vector and `b`. This method runs faster than DistanceTo(Vector3), so prefer it if you need to compare vectors or need the squared distance for some formula.
Public methodDistanceTo
Returns the distance between this vector and `b`.
Public methodDot
Returns the dot product of this vector and `b`.
Public methodEquals(Object) (Overrides ValueTypeEquals(Object).)
Public methodEquals(Vector3)
Public methodFloor
Returns a new vector with all components rounded down (towards negative infinity).
Public methodGetHashCode (Overrides ValueTypeGetHashCode.)
Public methodGetType (Inherited from Object.)
Public methodInverse
Returns the inverse of this vector. This is the same as `new Vector3(1 / v.x, 1 / v.y, 1 / v.z)`.
Public methodIsEqualApprox
Returns true if this vector and `other` are approximately equal, by running IsEqualApprox(Single, Single) on each component.
Public methodIsNormalized
Returns true if the vector is normalized, and false otherwise.
Public methodLength
Returns the length (magnitude) of this vector.
Public methodLengthSquared
Returns the squared length (squared magnitude) of this vector. This method runs faster than Length, so prefer it if you need to compare vectors or need the squared length for some formula.
Public methodLinearInterpolate(Vector3, Vector3)
Returns the result of the linear interpolation between this vector and `to` by the vector amount `weight`.
Public methodLinearInterpolate(Vector3, Single)
Returns the result of the linear interpolation between this vector and `to` by amount `weight`.
Public methodMaxAxis
Returns the axis of the vector's largest value. See Vector3Axis. If all components are equal, this method returns X.
Public methodMinAxis
Returns the axis of the vector's smallest value. See Vector3Axis. If all components are equal, this method returns Z.
Public methodMoveToward
Moves this vector toward `to` by the fixed `delta` amount.
Public methodNormalized
Returns the vector scaled to unit length. Equivalent to `v / v.Length()`.
Public methodOuter
Returns the outer product with `b`.
Public methodPosMod(Single)
Returns a vector composed of the PosMod(Single, Single) of this vector's components and `mod`.
Public methodPosMod(Vector3)
Returns a vector composed of the PosMod(Single, Single) of this vector's components and `modv`'s components.
Public methodProject
Returns this vector projected onto another vector `b`.
Public methodReflect
Returns this vector reflected from a plane defined by the given `normal`.
Public methodRotated
Rotates this vector around a given `axis` vector by `phi` radians. The `axis` vector must be a normalized vector.
Public methodRound
Returns this vector with all components rounded to the nearest integer, with halfway cases rounded towards the nearest multiple of two.
Public methodSet(Vector3) Obsolete.
Public methodSet(Single, Single, Single) Obsolete.
Public methodSign
Returns a vector with each component set to one or negative one, depending on the signs of this vector's components, or zero if the component is zero, by calling Sign(Single) on each component.
Public methodSlerp
Returns the result of the spherical linear interpolation between this vector and `to` by amount `weight`. Note: Both vectors must be normalized.
Public methodSlide
Returns this vector slid along a plane defined by the given normal.
Public methodSnapped
Returns this vector with each component snapped to the nearest multiple of `step`. This can also be used to round to an arbitrary number of decimals.
Public methodToDiagonalMatrix
Returns a diagonal matrix with the vector as main diagonal. This is equivalent to a Basis with no rotation or shearing and this vector's components set as the scale.
Public methodToString (Overrides ValueTypeToString.)
Public methodToString(String)
Top
Operators
Fields
  NameDescription
Public fieldx
The vector's X component. Also accessible by using the index position `[0]`.
Public fieldy
The vector's Y component. Also accessible by using the index position `[1]`.
Public fieldz
The vector's Z component. Also accessible by using the index position `[2]`.
Top
See Also