struct

Godot::Vector2

Inherits Struct < Value < Object

2-element structure that can be used to represent 2D coordinates or vectors with 32-bit floating point precision.

Constants

DOWN = Vector2.new(0.0_f32, 1.0_f32)
INF = Vector2.new(Float32::INFINITY, Float32::INFINITY)
LEFT = Vector2.new(-1.0_f32, 0.0_f32)
ONE = Vector2.new(1.0_f32, 1.0_f32)
RIGHT = Vector2.new(1.0_f32, 0.0_f32)
UP = Vector2.new(0.0_f32, -1.0_f32)
ZERO = Vector2.new(0.0_f32, 0.0_f32)

Constructors

new(x : Float32 = 0.0_f32, y : Float32 = 0.0_f32)
Source
new(x : Number, y : Number)
Source

Instance methods

*(scalar : Number) : Vector2
Source
*(other : Vector2) : Vector2
Source
+(other : Vector2) : Vector2
Source
-(other : Vector2) : Vector2
Source
/(scalar : Number) : Vector2
Source
/(other : Vector2) : Vector2
Source
angle

Returns the angle in radians of this vector with respect to the positive X-axis.

Source
angle_to(to : Vector2) : Float32

Returns the unsigned angle in radians between this vector and other.

Source
angle_to_point(to : Vector2) : Float32

Returns the angle in radians between this vector and the given point.

Source
aspect
Source
bounce(normal : Vector2) : Vector2

Returns a new vector bounced off a plane defined by the given normal.

Source
ceil
Source
clamp(min : Vector2, max : Vector2) : Vector2

Clamps each component between min and max.

Source
cross(other : Vector2) : Float32
Source
direction_to(other : Vector2) : Vector2

Returns the normalized direction from this vector toward other.

Source
distance_squared_to(other : Vector2) : Float32

Returns the squared distance between this vector and other.

Source
distance_to(other : Vector2) : Float32

Returns the distance between this vector and other.

Source
dot(other : Vector2) : Float32
Source
floor
Source
is_equal_approx(other : Vector2) : Bool
Source
is_normalized?
Source
is_zero_approx
Source
length
Source
length_squared
Source
lerp(to : Vector2, weight : Number) : Vector2

Linearly interpolates between this vector and to by weight.

Source
limit_length(max_length : Number = 1.0) : Vector2

Clamps the vector's length to max_length.

Source
max(other : Vector2) : Vector2
Source
min(other : Vector2) : Vector2
Source
move_toward(to : Vector2, delta : Number) : Vector2

Moves this vector toward to by the given delta amount, never exceeding to.

Source
normalized
Source
orthogonal

Returns the vector rotated 90 degrees counter-clockwise.

Source
perpendicular

Alias for orthogonal.

Source
project(b : Vector2) : Vector2

Projects this vector onto vector b.

Source
reflect(normal : Vector2) : Vector2

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

Source
rotated(angle : Number) : Vector2

Rotates this vector by the given angle in radians.

Source
round
Source
sign
Source
slerp(to : Vector2, weight : Number) : Vector2

Spherically interpolates between this vector and to by weight.

Source
slide(normal : Vector2) : Vector2

Returns a new vector slid along a plane defined by the given normal.

Source
to_i
Source
to_s(io : IO) : Void

Same as #inspect(io).

Source
x=(x : Float32)
Source
y=(y : Float32)
Source