Determine if node is moving, but filter out small movements

I need to determine if an object is moving, but filter out small movements.

I figure getting the speed of the object would be: speed = (curPos - lasPos) * elapsedTime.

I’m not sure how to do this in code as the difference in positions would still return a Vec3 and not a single value to multiply it by the elapsed time.

Once I have the speed, I could filter out small movements by: if speed > 1: objectMoving = True

Thanks.

I think you want the length of the vector: (curPos - lasPos).length() * elapsedTime

Thanks. Is there any equivalent for Hpr - how much the object has rotated over time?

You could save your current and last rotation as quaternions. There’s even a handy method for the comparison:

curRot = np.getQuat() # np is your NodePath object

if curRot.almostSameDirection(lasRot, threshold): …

lasRot = curRot