How to get speed of an object. Which one is correct ?

Technically, none of them.

Speed is the total distance traveled over time, therefore it’s a scalar value. To calculate the speed according to the literal definition, you first need to determine the time measurement unit. Because the value of speed changes depending on that. It could be val per seconds or val x 60 per minutes. Then you need to calculate the distance your character takes, which would require the use of splines. This was a more technical explanation but you can get the velocity using that node and get it’s length for a more practical solution.

If you mean velocity however, which means the change of location over time, you would again need to deterime a time measurement unit and then store the location using two variables, being the current one and the one before that amount of time. Then you would need to subtract those vector type variables which give us two locations and then get the vector length of it. You can also get the velocity of your object easily using that node but since velocity is a vector type value, you would need to keep that as it is and not get it’s magnitude.

Hope this helps!

1 Like