19.05.2009, 00:16
Pythagoras states that when a is the hypotenuse of a triangle, and b and c are the other sides, a^2 = b^2 + c^2.
If you have a line going from one corner of a cube to the opposite, the length of the line is root(side x side x side). So to find the distance a player moved since the last time you checked, work out the difference in X Y and Z, square these differences, add them, and root the lot. This gives you distance...
Speed = Distance/Time... you know Distance and Time by this stage, so you can work out the players speed.
If you have a line going from one corner of a cube to the opposite, the length of the line is root(side x side x side). So to find the distance a player moved since the last time you checked, work out the difference in X Y and Z, square these differences, add them, and root the lot. This gives you distance...
Speed = Distance/Time... you know Distance and Time by this stage, so you can work out the players speed.