gdscript vector2

The GDScript Vector2 class is used in the Godot game engine to represent a 2D vector. It provides various methods and properties for working with 2D vectors. Here's an example of how to use the Vector2 class in GDScript:

# Create a Vector2 instance
var vector = Vector2(1, 2)

# Access the x and y components of the vector
var x = vector.x
var y = vector.y

# Set the x and y components of the vector
vector.x = 3
vector.y = 4

# Perform operations on vectors
var sum = vector + Vector2(5, 6)
var difference = vector - Vector2(7, 8)
var scaled = vector * 2
var normalized = vector.normalized()

# Calculate the length of the vector
var length = vector.length()

# Check if two vectors are equal
var equal = vector == Vector2(1, 2)

Please note that the code provided is a basic example and there are many more methods and properties available in the Vector2 class. For more information, you can refer to the official Godot documentation on the Vector2 class.