I have several objects in the scene, each of them has few shape keys. All shape key values change simultaneously with the same value. Every time I need to keyframe the animation I have to go to every object and keyframe each shape key's value. Is there a way to somehow make these values bound? So, if I change one 'master' key shape value, the rest of the key shapes in other objects change the value as well.
Yes, you can definitely do this with drivers. Here's how:
In this first image you can see that I've created 2 spheres, each with a Basis shapekey. Sphere 1 has a second shapekey called Sphere1Key, which changes the sphere to a fatter shape. This key is animated (keyframed) from 0 to 1 over 50 frames. You can see the value field is green due to the keyframed status.
The second sphere also has a second shapekey called Sphere2Key, which deforms the sphere in the same way.
For the Sphere2Key shapekey, I have right clicked on the value field and selected Add Driver.
With Sphere 2 still selected I open up the Graph Editor and switch from F-Curve Drivers mode with the dropmenu in the toolbar.
You can see in the left panel that the Sphere.001 is selected and I've also selected the Value for the Sphere2Key shapekey.
Now we just have to map the value from the first sphere's shapekey to this one.
To do this, press N to bring up the right property panel. In the Drivers area we want these settings:
- Change type to Scripted Expression.
- In Expr, add a variable name (I've used getSphere1KeyValue)
- Click Add Variable button
- In the variable name field paste in the name from the Expr box above (getSphere1KeyValue)
- Change the variable type to Single Property
- Change the Prop type to Key
- Change the selected Key id block to "Key" or whatever the name of the id block for the keyframed data for the Sphere1 shapekey value is (The available values list automatically when you click in this field. If you're not sure what it should be you can select Sphere1 and the switch to the Dope Sheet and find it there).
- Enter the RNA path to the sphere 1 key value into the Path field. You can get this value by right clicking on the Sphere1Key field in the shapekeys panel, and choosing Copy Data Path.
- The value for the Value field in the Driver panel should now update when you scroll the timeline back and forth.
- If the Sphere2 shapekey doesn't respond, you may need to click the Update Dependencies button in the driver panel. You should then see the Sphere2 shapekey copy the Sphere1 shapekey keyframed values in synchronization.
Note: you may notice in the gif that the numbers in the Value field are not changing while the animation runs. This is simply a UI display issue, the actual values are changing, as evidenced by the shape change in Sphere.001. If you hover the cursor over those fields you'll see them update.
As Todd mentioned, drivers can be used to achieve that. Yet I would prefer to create an additional object which will be a master control.
Generally I prefer an Empty for that (called Master in my scene). Also, here are the objects: a cylinder with a shape key that makes it taller, and a cube with a shape key that makes it wider:
- Select one of the objects, hover over one of its shape key's Value and press D, that adds the driver to it.
- Go to graph editor and press N to bring up the properties panel. Also, select Drivers at the bottom.
- Select your shape key at the left side. In the properties panel go to Drivers tab. If you don't have a variable there right away (
varin my case), then click Add Variable.
It can be easier to operate with the size of your master Empty in this case. Under the
varselect Transform Channel in the dropdown menu, select Master in Ob/Bone field and select Z Scale in Type (you can use Master's location or rotation instead, choose the corresponding entry in this menu then).
Now you need to write an expression under Expr. I wrote
var-1in my example, because I wanted my shape key value to be
0when the scale of my Master empty is
1. You can write whichever you need.
Note: You can write
3*var-1 (or any other multiplier) to make your shape keys affected more. I use it to scale when I create music visuals, because the curves baked from sound (which I apply to Master empties) are not editable by default.
Now try scaling your empty. The object should react.
Now go to your object (cube in my case), right click on the shape key Value > Copy Driver. Go to your another object, right click the Value > Paste driver.
Now both objects should react to the change of the scale of the Master empty. If the second one doesn't, you may go to its driver properties in graph editor and click Update Dependencies.
Now just go ahead and animate your Master empty's scale.
Hope it helps.