# Offset on driver via scripted expression

I am trying to rotate a set of limbs on a centipede all slightly offset from each other in a 360 degree cycle. Each one will have a driver with an offset, thus the centipede would walk as seen here https://www.youtube.com/watch?v=ivWcwgfWR7Y

The turning of a main control wheel offsets the y-height of the target bone by x amount.

The driver so far is this

sin(abs(v*.25))*.9


where v (var) is the z rotation of main wheel, and drives the y height of bone. How can I offset the expression so that, say, plus %10 of rotation causes the next limb to lag or lead height by 10 percent?

Note that the wheel is located toward center/root of centipede.

Use self and a custom property

Offsets L to R, -pi / 2, -pi / 4, 0, pi / 4, pi / 2

Using a simple example with 5 cubes as feet and another as the wheel.

Add a custom property to foot, if you are driving a pose bone add a custom property to the bone.

Helper script to add a custom property named "offset" (edit to suit) to all selected pose bones.

import bpy
from bpy import context

propname = "offset"

for pb in context.selected_pose_bones:
pb[propname] = 0.0 # set a float proprty


Drivers have a use self option. When on self in an expression refers to the object being driven. The custom property on the object can be added to an expression as self["prop"] Pick a better name than prop.

'rot' is a variable set up as usual getting the local rotation of the spinning cube. We offset that rotation by adding the value of the property to it.

abs(sin(rot + self["prop"]))

• I'm implementing this now...gonna accept once its working. Are you using the new Blender beta? Some things seem different on my end. – Leo Blanchette Mar 10 '19 at 5:21
• Yes I'm using 2.8. Everything mentioned is available in 2.79. – batFINGER Mar 10 '19 at 7:01