+1 vote

know some basic python, also wrote some small scripts in past(web scrapping, brute force), now i want to move on game development, so choose go with godot.

i was looking GDscript syntax, came to this part:

# built-in vector types

var v2 = Vector2(1, 2)
var v3 = Vector3(1, 2, 3)

i don't know what are vectors, and for what purpose these use?

is it related to physics,

I have done my graduation from ARTS. so never faced this word, neither in python,
can anyone explain what it is?
and what are uses of vector in gaming?


asked Nov 17, 2017 in Engine by learner (21 points)

3 Answers

+3 votes
Best answer

A Vector2 or Vector3 represents the coodinates of a point in space, or a translation depending on how you use it. In other frameworks you can also find it named a Point2D, Size2D, sometimes simply a tuple of 2 or 3 numbers etc. They all are the same thing, but in Godot it gets its own naming because it is used a lot.

For example, player position in a 2D game will be stored in a Vector2 (x, y). In 3D there are 3 dimensions (x, y, z) so it would be a Vector3.

You can add and subtract vectors together. For example, moving a character requires to add a value to its X and Y coordinates:

# Moves 10 pixels to the right and 5 pixels up
position = position + Vector2(10, -5)

There is a whole field of mathematics dedicated to vectors (part of linear algebra) which is very useful to know in game developement.

You should (must!) read the documentation linked by hungrymonkey because it explains more about it ;)

answered Nov 17, 2017 by Zylann (26,157 points)
selected Nov 22, 2017 by learner
0 votes

Vector in godot is kinda like physics or transformation vectors.

It is pretty much a generalize data type in math that have tons of applications.


the docs are pretty helpful, you should read it

answered Nov 17, 2017 by hungrymonkey (427 points)
0 votes

You can find out more about what vectors are and how they are used in Godot by referring to the following two links.



answered Nov 22, 2018 by LeeJiwon (18 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.