Why use a vector to represent speed in a game?
Technically speaking, length divided by time gives you speed, not speed. Speed ββdoes not tell you which direction you are traveling, while speed does. In 3D space, to describe where you are going and how fast, you need to specify three values: the direction and the speed you are in, in each of three main directions (commonly called axes and called x, y, and z). But you can refer to them as forward / backward, sideways and up / down if you like. For example, if you are traveling at 5 km / h upwards, the vector might be (0,0,5). Traveling 5 km / h down, your speed will be the same, but the vector will be (0,0, -5). Traveling at 5 km / h at an angle of 45 degrees forward, the SPEED along each of the x and z axes will be the square root of 5, so the vector will be (approximately) (2,2,0,2,2). Etc.
a source to share
You would use a vector because you can have velocity in 3 dimensions. In other words, 3D speed is a combination of distance / time in all three dimensions. It might be better to name the variables xPrime, yPrime, and zPrime so that the vector more clearly represents velocity rather than position.
a source to share