Vector used for 2D math.
``````    [Serializable]
public struct Vector2 : IEquatable<Vector2>
``````

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

### Static Properties

``````    public static  Down { 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 Vector2(float x, float y)
``````

Constructs a new Vector2 from the given `x` and `y`.

``````    public Vector2(Vector2 v)
``````

``````    public Vector2()
``````

### Fields

``````    public Single x
``````

The vector’s X component. Also accessible by using the index position ``.

``````    public Single y
``````

The vector’s Y component. Also accessible by using the index position ``.

### Properties

``````    public float this[] { get; set; }
``````

### Methods

``````    public Vector2 Abs()
``````

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

``````    public float Angle()
``````

Returns the vector’s angle in radians with respect to the X axis, or `(1, 0)` vector.

Equivalent to the result of [method @GDScript.atan2] when called with the vector’s Axis.X and Axis.Y as parameters: `atan2(x, y)`.

``````    public float AngleTo(Vector2 to)
``````

Returns the angle in radians between the two vectors.

``````    public float AngleToPoint(Vector2 to)
``````

Returns the angle in radians between the line connecting the two points and the X coordinate.

``````    public float Aspect()
``````

Returns the ratio of Axis.X to Axis.Y.

``````    public Vector2 Bounce(Vector2 n)
``````

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

``````    public Vector2 Ceil()
``````

Returns the vector with all components rounded up.

``````    public Vector2 Clamped(float length)
``````

Returns the vector with a maximum length.

``````    public float Cross(Vector2 b)
``````

Returns the 2-dimensional analog of the cross product with the given vector.

``````    public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, float t)
``````

Cubically interpolates between this vector and `b` using `preA` and `postB` as handles, and returns the result at position `t`. `t` is in the range of `0.0 - 1.0`, representing the amount of interpolation.

``````    public Vector2 DirectionTo(Vector2 b)
``````

Returns the normalized vector pointing from this vector to `b`.

``````    public float DistanceSquaredTo(Vector2 to)
``````

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

``````    public float DistanceTo(Vector2 to)
``````

Returns the distance to vector `b`.

``````    public float Dot(Vector2 with)
``````

Returns the dot product with vector `b`.

``````    public override bool Equals(object obj)
``````

``````    public bool Equals(Vector2 other)
``````

``````    public Vector2 Floor()
``````

Returns the vector with all components rounded down.

``````    public override int GetHashCode()
``````

``````    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 method over Length() if you need to sort vectors or need the squared length for some formula.

``````    public Vector2 LinearInterpolate(Vector2 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 Vector2 MoveToward(Vector2 to, float delta)
``````

Moves the vector toward `to` by the fixed `delta` amount.

``````    public Vector2 Normalized()
``````

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

``````    public Vector2 PosMod(float mod)
``````

Returns a vector composed of the `fposmod` of this vector’s components and `mod`.

``````    public Vector2 PosMod(Vector2 modv)
``````

``````    public Vector2 Project(Vector2 onNormal)
``````

Returns the vector projected onto the vector `b`.

``````    public Vector2 Reflect(Vector2 n)
``````

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

``````    public Vector2 Rotated(float phi)
``````

Returns the vector rotated by `phi` radians. See also [method @GDScript.deg2rad].

``````    public Vector2 Round()
``````

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

``````    [Obsolete("Set is deprecated. Use the Vector2(real_t, real_t) constructor instead.", true)]
public void Set(float x, float y)
``````

``````    [Obsolete("Set is deprecated. Use the Vector2(Vector2) constructor instead.", true)]
public void Set(Vector2 v)
``````

``````    public Vector2 Sign()
``````

Returns the vector with each component set to one or negative one, depending on the signs of the components.

``````    public Vector2 Slerp(Vector2 b, float t)
``````

Returns the result of spherical 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.

Note: Both vectors must be normalized.

``````    public Vector2 Slide(Vector2 n)
``````

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

``````    public Vector2 Snapped(Vector2 by)
``````

Returns the vector snapped to a grid with the given size.

``````    public Vector2 Tangent()
``````

Returns a perpendicular vector.

``````    public override string ToString()
``````

``````    public string ToString(string format)
``````

### Operators

``````    public static Vector2 operator +(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator /(Vector2 vec, float scale)
``````

``````    public static Vector2 operator /(Vector2 left, Vector2 right)
``````

``````    public static bool operator ==(Vector2 left, Vector2 right)
``````

``````    public static bool operator >(Vector2 left, Vector2 right)
``````

``````    public static bool operator >=(Vector2 left, Vector2 right)
``````

``````    public static bool operator !=(Vector2 left, Vector2 right)
``````

``````    public static bool operator <(Vector2 left, Vector2 right)
``````

``````    public static bool operator <=(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator %(Vector2 vec, float divisor)
``````

``````    public static Vector2 operator %(Vector2 vec, Vector2 divisorv)
``````

``````    public static Vector2 operator *(Vector2 vec, float scale)
``````

``````    public static Vector2 operator *(float scale, Vector2 vec)
``````

``````    public static Vector2 operator *(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator -(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator -(Vector2 vec)
``````

### Inner Types

#### Axis

Name Value Description
X
Y
Tags: