In math, a vector is a list of numbers representing a direction and a length (called the vector's magnitude).In math, a vector can be a list of numbers of any length, though in games, we mostly use vectors to represent 2D and 3D coordinates. So, we mostly use vectors with 2 and 3 numbers.A 2D vector has two values representing the x and y coordinates, while a 3D vector has three values for the x, y, and z coordinates.In Godot, vectors are essential for representing positions, velocities, and forces within a game world. We use them in scripts to control characters, detect collisions, and more. Godot provides two primary vector types: Vector2 for 2D, and Vector3 for 3D.
Common vector operations
You can manipulate vectors with various operations, including:
Addition and subtraction: You can use this to move a sprite or a character in the game world.
Multiplication and division: You can scale vectors by multiplying or dividing them by a number.