I don't understand Vector2 + Vector3

If anyone could help me understand Vectors that would be great as I want to create a 2d platformer with cubes. I’m quite knowledgeable with javascript but when I watch and read tutorials, they use vectors to create a jump script and a good movement script. But I don’t understand how vectors work and what they are for, if anyone could leave a detailed explanation or video tutorial on how to use vectors in unity3d that would be great. Thanks.

The concept of vector is broader than Unity in fact it comes from mathematics, usually studied in the early years of high school.

I recommend you to have a look at this video What are Vectors, where you can find information about what they are and some of their operations (addition, product, etc).
Please also check this website, Vectors for beginners, which I believe will clarify most of the questions you have at this stage.

2D and 3D vectors are essentially the same, only that 2D vectors only have 2 components (x,y), while 3D vectors have 3 (x,y,z).

In Unity you will be mostly working with 3D vectors as the space is three-dimensional. However, all of the operations apply to both type, and are similar.

Vectors aren’t Unity specific.

Search engines are your friend.

Vectors Third Party

Unity Learn Primer

A Vector2 stores two floats, one for your X position and one for your Y position in cartesian coordinates. A Vector3 adds the Z position.

Say you wanted to move your character along the x axis. You can simply access the player’s x value. You could do this with transform.Translate(5,0,0), where the character will move at a speed of five along the x, or you could access the x variable inside the transform.position Vector3 : transform.position.x += 5. Obviously you’d want to use time.DeltaTime and magic numbers are a no go but basically a Vector2 or a Vector3 are just two or three floats in one easy to manage variable :slight_smile: