+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?

thanks.

asked Nov 17, 2017 in Engine

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.

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

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.

http://docs.godotengine.org/en/stable/learning/features/math/vector_math.html