# : How do vectors work in 3d movement?

137 views
0

I started programming when I was 7 and all the 2d movement was straight forward. Now I’m 13 and I can’t understand unity’s 3d movement with vector3. The movement is bad and I work of tutorials for it. The same is for a lot of game engines.

In: 3

Can you be more specific about what is confusing to you? What are your expectations about how this works and how does that mismatch the reality of what you’re seeing?

You know how a 2D vector [x,y] is just how far you go left/right and up/down? a 3d vector [x,y,z] exactly the same but you’ve also got an additional number for how far up and down you go.

Unities Vector3 is the same, but maybe you’re not quite used to the order. A vector3 is a vector composed of [x,y,z], where x is “left/right”, y is “up/down”, and z is “backwards/forwards”.

So let’s say you want to move something up four units, and two units to the right. That would be Vector3(2,-4,0): Move right 2, up 4, forwards 0.

A vector3 is 3 floating point numbers one for x, y and z and gives you a point in space. If you have 2 of them, you can draw a line between point 1 and point 2, if you make an object follow that line over a set period of time you can make it move.

The vector3 can help give you an arrow, and the length of the arrow is the velocity of the vector.

The difference between 2D and 3D is that in 2D you only have 1 plane that an object can move on, in 3D there are 2 more planes at 90 degree angles to the others.