Changing a driver during animation

Hello,

I have an object and I attached a driver to its Z axis which is copying X axis position from object 2. Just an ordinary simple driver.

But then, during a certain point in an animation I need to change this driver so instead it’s copying Y axis position from object 3.

Basically what I need to know is, how I can “keyframe” a driver so i can swap it out for a different one at a certain point in the animation.

Thanks

Hi,

I’ve checking on the UI in Blender, but there doesn’t seem to be any basic way of making a Driver ‘Dynamic’. Drivers are used for making certain thinks ‘dynamic’, but I think they themselves, can’t be ‘dynamized’; meaning: it doesn’t seem (at least, not readily) possible to Drive a Driver.

i) There could be workarounds though; for example, on the same Driver, it is possible to Add Input Variables. Each Input Variable would bring new Input Data (X Rotation on Local Space for Target A; Z Location on World Space for Target B; and so forth). Unfortunately, these Inputs will all stack together on a single Output, which is directly related to the ‘thing’ on which Driver was Added to.
So, multiple Inputs (I₁, I₂, I₃, …) → affecting only 1 Output (O) per Driver… Unless there is some fundamental thing I am missing.
Perhaps, with Scripted Expression (and some smart formula) there would be a mathematical way to ‘counter’, for example, the I₁, as the I₂ gets into play and vice-verse, for the unique Ouptut.

ii) Another workaround, which I think is much better, depending on which settings you need to Transform in your project, is to just use Transfomation Constraint/Bone Constraint.
It allows for Transforming (just as certain uses of Drivers), proportionally, a Transform A from something (Map From; Target), into a Transform B of something else (Map To; Owner).
The great advantage, is that, being a Constraint/Bone Constraint, you can actually Key Frame the Toggling ON/OFF of that thing in 3D Animation. And you may have as many different Transformation Bone Constraints you want, for the same or for different elements of the Scene. However, Transformation Constraint/Bone Constraint is a bit difficult to use if you never used it (but there are some good tutorials already about it); moreover, they cannot do everything Drivers do: Drivers are more versatile on this matter, although Drivers are, very often not convenient. Finally, Transformation Constraint/Bone Constraint has got a Mix: Add/Replace setting; which allows for some interesting tricks.

1 Like

Or, make two new objects (empties, prob), give them the different drivers, and copy transforms from those empties, with animated influence.

1 Like

var1(mix) + var2(1-mix) .

1 Like

Interesting; I’ve never used that mix functionality. What would that do (or ‘mix’) actually? Thanks!
Would this be part of a solution for the topic’s problem? (as you’ve written it, sounds like for the ‘countering’ proposition).

You were talking about mixing two different expressions in a single driver, if I understood you correctly.

Let’s say you have 2 expressions, f(x) and g(x), and you want to mix between them. Let’s create a new variable, called “mix”, and then set the expression to be (mix * f(x)) + ((1-mix) * g(x)) . Now, when mix is 0, you’re using g(x), when it’s 1, you’re using f(x), and when it’s inbetween, you’re interpolating (linearly) between the two.

1 Like

Oh, I see! Neat; ‘mix’ was just an arbitrary name for another one “var”. I first thought it was a Scripted Expression command.

This would indeed totally suppress the ‘influence’, either from one or the other expression, and even hold an inversely proportional system, I assume. I’ll keep this in mind regarding certain Drivers’ uses; I just don’t have any application right now, but this is quite interesting approach.

Here’s my take on it.

I used a python driver and put a custom property on Suzanne called Driver_Select. If Driver_Select is 0, the Suzanne’s z loc is driven by Object2, the cube. If Driver_Select is 1, Suzanne’s location is driven by Object3, the icosphere.

Here’s the file:
py_driver_example.blend (890.8 KB)

If you try this file and are prompted to allow execution of python scripts, allow execution. In the driver panel, if there is an error message about an invalid python expression, then click in the expression box and hit return. That should fix everything.

This error occurs because by default, blender is set to not auto-execute python scripts contained in files. It’a security measure and enabling auto execution of python scripts in user prefs should fix the problem.

Comments welcomed,
Randy

2 Likes