Get object speed?

Hello.

Is there a way to get the speed of an object? I know how to get the linear velocity, but I don’t want the xyz portions, I just want it as one number so that I can use it in calculations.

Thanks.

Edit: Or if there is a way to get the displacement of an object, like when you move an object in the 3d viewport, it shows the separate xyz portions of the movement, but then in brackets it shows the displacement as one number. That is the number I want to find.

Linear velocity is a vector, so the overall speed is just the magnitude of that vector.

An easy way to get it:


from Mathutils import Vector

linv_vec = Vector(own.getLinearVelocity())
print "Speed:", linv_vec.magnitude

Well then. That is much easier than I was expecting. Thank you very much.

I should really study python more.