TransWikia.com

Shape key animation applies to all animation actions, how do I only apply it to one?

Blender Asked on December 7, 2021

Like the title says, I’ve been learning how to use shape keys, and need to change the value differently based on my animation. But when I make one shape key animation it applies to all of my actions. Would appreciate any ideas on how to have separate shape key animations for each action

2 Answers

Drive the shape keys

Instead of keyframing shapekeys can drive them with a custom property on the object you are animating. Change and keyframe the custom property. Keeping you to a single action.

Example image, Basis and five keys on the Cube Mesh. Five custom properties with matching name are added to Cube object. These can be keyframed, and for default scene example will become part of the "Cube" objects "CubeAction" along with transforms etc.

enter image description here

From Python: drive a shape key with scripting

There is a script to set up the custom properties and drivers for you.

Converting Shapekey Action to Object Action

If you already have a shape key animation, this will transfer it to object action as custom properties.

Eg the cube has an action "CubeAction" The shapekeys are part of action "Key.001Action"]

The datapath keyframed for the value of shapekey "Key 4" is

key_blocks["Key 4"].value

will convert to a fcurve on "CubeAction" with data path to custom property "Key 4"

["Key 4"]

and copy over the keyframes.

Conversion script, change name of shapekey and object animation to suit.

import bpy

context = bpy.context

sk_action = bpy.data.actions["Key.001Action"]
ob_action = bpy.data.actions["CubeAction"]

for fc in sk_action.fcurves:
    data = [0.0] * 2 * len(fc.keyframe_points)
    fc.keyframe_points.foreach_get("co", data)
    dp = fc.data_path[len('key_blocks'):-len('.value')]
    ofc = ob_action.fcurves.find(dp)
    if ofc:
        ob_action.fcurves.remove(ofc)
    ofc = ob_action.fcurves.new(dp)
    ofc.keyframe_points.add(len(fc.keyframe_points))
    ofc.keyframe_points.foreach_set("co", data)

Answered by batFINGER on December 7, 2021

I think you will need a different shape key animation for every action. To simplify this you can copy the shape key you already have.

It's sometimes hard to notice but you have to click the little downward pointing ">" icon. Make sure you have only the correct shape key activated by having its checkbox checked, and having the other shape keys unchecked (since the new shape key will be a combination of all the activated shape keys). Then have the Value set to the correct value (in this case 1), and then choose New Shape From Mix.

enter image description here

Answered by Fjoersteller on December 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP