Get velocity of dynamic object?

Trying to get velocity of dynamic object in python, but it just gives weird values for objects that are not static.
Used getLinearVelocity() as well as worldLinearVelocity and individual axises of them, in every case if object is static, it gives right velocity values, and when it’s dynamic (or any other type) it gives weird values like (0.0003, 0, 0.0005) and also giving non-zero values when my character doesnt move at all.

Better post a blend.

I think getLinearVelocity() function works only if a force or a linear velocity is applied on the object (if the object has inertia). Not a simple applyMovement. But I could make a mistake…

If you look at the blender terminal, you can see that cube velocity is (0,0,0), but obviously it isnt. If you switch cube physics type from dynamic to static it would give correct velocity (which is 6,0,0).
test.blend (457 KB)

Try using force instead of Location.
Location just offsets the object’s position, and doesn’t apply any force to the object.
No force on the object, and the object has no velocity.
Force cannot be applied to static objects (although static objects can be teleported)
Gravity is a force which is giving you your negative Z values when you change it to dynamic (negative Z being ‘down’)

And: You can use cube.getLinearVeloctiy().magnitude if you want a meters-per-second type of velocity read-out.

That seems to be the problem, when switched from setting location to applying force, getLinearVelocity() started to give correct values. Thanks.

Just to clarify, getLinearVelocity() was never giving you “incorrect” values. When you move an object by setting its location (e.g. by using the location motion type or setting worldPosition in a Python script), you only change its position, not its velocity. Think of it as instantly teleporting the object. It never actually moves between the positions, so it never gains velocity from the change.