Api Vector2Int
struct

Vector2Int

public sealed struct Vector2Int

Constructors

Vector2Int(Int32 x, Int32 y)

Initializes an integer vector with given components.

x — The X component.
y — The Y component.
Vector2Int(Int32 all)

Initializes an integer vector with all components set to the same value.

all — The value of the X and Y components.
Vector2Int(Vector2Int vector2Int)

Initializes an integer vector with given components from another integer vector.

Vector2Int(Vector3Int vector3Int)

Initializes an integer vector with given components from another integer vector, discarding the Z component.

Properties

Name Type Description
Normal Vector2 Returns a unit version of this vector. Keep in mind this returns a Vector2 and not a Vector2Int.
Degrees Single Return the angle of this vector in degrees, always between 0 and 360.
Item Int32
Length Single Length (or magnitude) of the integer vector (Distance from 0,0)
LengthSquared Int32 Squared length of the integer vector. This is faster than Length, and can be used for things like comparing distances, as long as only squared values are used."/>
Perpendicular Vector2Int Returns an integer vector that runs perpendicular to this one.
IsZeroLength Boolean Whether the length of this vector is zero or not.

Methods

Boolean IsNearlyZero(Int32 tolerance = 0)

Returns true if value on every axis is less than or equal to tolerance

Void Write(BinaryWriter writer)
Vector2Int Read(BinaryReader reader)
Vector2Int ComponentMin(Vector2Int other)

Returns an integer vector that has the minimum values on each axis of the two input vectors.

Vector2Int ComponentMax(Vector2Int other)

Returns an integer vector that has the maximum values on each axis of the two input vectors.

Single Distance(Vector2Int other)

Returns the distance between this vector and another.

Single Distance(Vector2 other)

Returns the distance between this vector and another.

Vector2Int SnapToGrid(Int32 gridSize, Boolean sx = True, Boolean sy = True)

Snap to grid along any of the 2 axes.

static Vector2Int Min(Vector2Int a, Vector2Int b)

Returns an integer vector that has the minimum values on each axis between 2 given vectors.

static Vector2Int Max(Vector2Int a, Vector2Int b)

Returns an integer vector that has the maximum values on each axis between 2 given vectors.

Vector2Int Abs()

Returns a new integer vector with all values positive. -5 becomes 5, ect.

Vector2Int WithX(Int32 x)

Returns this integer vector with given X component.

Vector2Int WithY(Int32 y)

Returns this integer vector with given Y component.

static Vector2Int Parse(String str)

Given a string, try to convert this into a Vector2Int. Example formatting is "x,y", "[x,y]", "x y", etc.

static override Vector2Int Parse(String str, IFormatProvider provider)
static override Boolean TryParse(String str, IFormatProvider info, Vector2Int result)

Fields

Name Type Description
x Int32 The X component of this integer vector.
y Int32 The Y component of this integer vector.
One static Vector2Int An integer vector with all components set to 1.
Zero static Vector2Int An integer vector with all components set to 0.
Right static Vector2Int An integer vector with X set to 1. This represents the right direction.
Left static Vector2Int An integer vector with X set to -1. This represents the left direction.
Up static Vector2Int An integer vector with Y set to 1. This represents the up direction.
Down static Vector2Int An integer vector with Y set to -1. This represents the down direction.
Assembly: Sandbox.System Full Name: Vector2Int