Tracking Movement

Is there a way to see in a script how much an object has moved since the last frame, or since the last time the script was executed? I can’t seem to find a python equivelant of C’s “static” variable declaration…

use ‘global’ keyword

Hmm, if I declare a variable as “global”, then incriment it each time the script is executed, then the value remains the same, no matter how many times I execute the script. Isn’t there any Blender API that will tell you how much an object has moved since the last frame?

Try this code:

import Blender
if hasattr(Blender,'x') == 0:
  Blender.x = 0
Blender.x += 1
print Blender.x 

Attach this script to Scene scriptlink on Frame Changed, and it will increment every time when frame changes.

Aha, that worked. Thanks!