Vector class, which performs basic 3D vector math operations.
    public struct Vector3 : IEquatable<Vector3>

Vector3 is one of the core classes of the engine, and includes several built-in helper functions to perform basic vector math operations.

Inheritance Chain

Interfaces

Static Properties

    public static  Back { get; }

    public static  Down { get; }

    public static  Forward { get; }

    public static  Inf { get; }

    public static  Left { get; }

    public static  NegOne { get; }

    public static  One { get; }

    public static  Right { get; }

    public static  Up { get; }

    public static  Zero { get; }

Constructors

    public Vector3(float x, float y, float z)

Returns a Vector3 with the given components.

    public Vector3(Vector3 v)

    public Vector3()

Fields

    public Single x

The vector’s x component. Also accessible by using the index position [0].

    public Single y

The vector’s y component. Also accessible by using the index position [1].

    public Single z

The vector’s z component. Also accessible by using the index position [2].

Properties

    public float this[] { get; set; }

Methods

    public Vector3 Abs()

Returns a new vector with all components in absolute values (i.e. positive).

    public float AngleTo(Vector3 to)

Returns the minimum angle to the given vector.

    public Vector3 Bounce(Vector3 n)

Returns the vector “bounced off” from a plane defined by the given normal.

    public Vector3 Ceil()

Returns a new vector with all components rounded up.

    public Vector3 Cross(Vector3 b)

Returns the cross product with b.

    public Vector3 CubicInterpolate(Vector3 b, Vector3 preA, Vector3 postB, float t)

Performs a cubic interpolation between vectors preA, a, b, postB (a is current), by the given amount t. t is in the range of 0.0 - 1.0, representing the amount of interpolation.

    public float DistanceSquaredTo(Vector3 b)

Returns the squared distance to b. Prefer this function over DistanceTo(Godot.Vector3) if you need to sort vectors or need the squared distance for some formula.

    public float DistanceTo(Vector3 b)

Returns the distance to b.

    public float Dot(Vector3 b)

Returns the dot product with b.

    public override bool Equals(object obj)

    public bool Equals(Vector3 other)

    public Vector3 Floor()

Returns a new vector with all components rounded down.

    public override int GetHashCode()

    public Vector3 Inverse()

Returns the inverse of the vector. This is the same as Vector3( 1.0 / v.x, 1.0 / v.y, 1.0 / v.z ).

    public bool IsNormalized()

Returns true if the vector is normalized.

    public float Length()

Returns the vector’s length.

    public float LengthSquared()

Returns the vector’s length squared. Prefer this function over Length() if you need to sort vectors or need the squared length for some formula.

    public Vector3 LinearInterpolate(Vector3 b, float t)

Returns the result of the linear interpolation between this vector and b by amount t. t is in the range of 0.0 - 1.0, representing the amount of interpolation..

    public Axis MaxAxis()

Returns the axis of the vector’s largest value. See AXIS_* constants.

    public Axis MinAxis()

Returns the axis of the vector’s smallest value. See AXIS_* constants.

    public Vector3 Normalized()

Returns the vector scaled to unit length. Equivalent to v / v.length().

    public Basis Outer(Vector3 b)

Returns the outer product with b.

    public Vector3 Project(Vector3 onNormal)

Returns the vector projected onto the vector b.

    public Vector3 Reflect(Vector3 n)

Returns the vector reflected from a plane defined by the given normal.

    public Vector3 Rotated(Vector3 axis, float phi)

Rotates the vector around a given axis by phi radians. The axis must be a normalized vector.

    public Vector3 Round()

Returns the vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.

    public void Set(float x, float y, float z)

    public void Set(Vector3 v)

    public Vector3 Slerp(Vector3 b, float t)

Returns the result of SLERP between this vector and b, by amount t. t is in the range of 0.0 - 1.0, representing the amount of interpolation.

Both vectors need to be normalized.

    public Vector3 Slide(Vector3 n)

Returns the component of the vector along a plane defined by the given normal.

    public Vector3 Snapped(Vector3 by)

Returns a copy of the vector, snapped to the lowest neared multiple.

    public Basis ToDiagonalMatrix()

Returns a diagonal matrix with the vector as main diagonal.

    public override string ToString()

    public string ToString(string format)

Operators

    public static Vector3 operator +(Vector3 left, Vector3 right)

    public static Vector3 operator /(Vector3 vec, float scale)

    public static Vector3 operator /(Vector3 left, Vector3 right)

    public static bool operator ==(Vector3 left, Vector3 right)

    public static bool operator >(Vector3 left, Vector3 right)

    public static bool operator >=(Vector3 left, Vector3 right)

    public static bool operator !=(Vector3 left, Vector3 right)

    public static bool operator <(Vector3 left, Vector3 right)

    public static bool operator <=(Vector3 left, Vector3 right)

    public static Vector3 operator *(Vector3 vec, float scale)

    public static Vector3 operator *(float scale, Vector3 vec)

    public static Vector3 operator *(Vector3 left, Vector3 right)

    public static Vector3 operator -(Vector3 left, Vector3 right)

    public static Vector3 operator -(Vector3 vec)

Inner Types

Axis

Name Value Description
X    
Y    
Z    
Tags: