← Back to 2D Structs

Vector2

⚠️ Experimental - Pre-Release

Vector2 represents a 2D vector with x and y components. Used for positions, directions, velocities, and other 2D values. Used by Transform2D for position and scale.

Fields

x: float

The x component of the vector.

y: float

The y component of the vector.

Usage Example

@script Player extends Node2D    var velocity = new Vector2(5.0, 0.0)     fn update() {        var delta = Time.get_delta()        self.transform.position.x += velocity.x * delta        self.transform.position.y += velocity.y * delta    }

Related