Blender doesn't give value changes off the sleeve. What you need is to evaluate an animation (F-Curve) in current and previous frames and compute the difference. This solution uses a script that adds a custom frame change handler. Other way could be with PyDrivers or using Animation Nodes plugin.
Run this, it will add new properties to objects and it will update them every frame. You can access them in driver:
import bpy
from mathutils import Vector, Euler
curr_frame = None
def frame_handler(scn):
global curr_frame
if curr_frame != scn.frame_current:
curr_frame = scn.frame_current
for obj in scn.objects:
obj.speed = (obj.matrix_world.translation - Vector(obj.last_loc)).length
last_quat = Euler(obj.last_rot).to_quaternion()
quat = obj.rotation_euler.to_quaternion()
obj.angular_speed = quat.rotation_difference(last_quat).angle
obj.last_loc = obj.matrix_world.translation
obj.last_rot = obj.rotation_euler
bpy.types.Object.last_loc = bpy.props.FloatVectorProperty()
bpy.types.Object.last_rot = bpy.props.FloatVectorProperty()
bpy.types.Object.speed = bpy.props.FloatProperty()
bpy.types.Object.angular_speed = bpy.props.FloatProperty()
if frame_handler not in bpy.app.handlers.frame_change_pre:
bpy.app.handlers.frame_change_pre.append(frame_handler)
Added props of interest are:
- speed (in blender units per frame)
- angular_speed (in rads per frame)
Use them in driver like this:
Here I am driving Y-scale and view-port material color with speed:
Note: this will only work when playing the frames sequentially. If you jump around you will get crazy values. This is a very simple handler using values from last and current frame, but it could be adjusted to read from the Fcurves of objects if you need.
Also it expects rotations in euler, but it transforms it to quaternions anyway. So if you want quaternions no problem.