I got an animation with blinking lights, animated by an emission and transparent node connected to a mix shader. I want them to go on and off after eachother, instead of all together at one time. Is their a possibility to shear these keyframes in the Dope Sheet? If I use the Shear tool it will crash, so is there a specific way to do this for keyframes?
-
1$\begingroup$ If any one need something like this use commotion add-on, it allows to easy copy animation from one object to another and offsetting time between them. You can easily adjust offset and it also have ready presets and it's free. $\endgroup$– genesis2303Nov 26, 2020 at 13:22
1 Answer
Assuming the lamps are sortable by their name and the animation (which is supposed to be shifted) is the only animation on the object, the you could use a python script to shift the keyframes of all fcurves of an object.
To use the script, selected the objects and execute the script. The selected objects must have an existing animation. First make sure to make the materials single user, by selecting all objects, then pressing U in the 3D View and choosing Material and Texture.
By changing the value of the offset_amount
variable, you can change the timing.
Decimal values 0 < x < 1
are also possible.
import bpy
offset_amount = 2.0
# get selected objects
sel = bpy.context.selected_objects
# sort them by name
sel.sort(key=lambda x: x.name)
# loop through all selected objects
for i, s in enumerate(sel):
# get the fcurves of the active action
# of the material of the object
fcurves = s.material_slots[0].material.node_tree.animation_data.action.fcurves
# loop through all fcurves
for fc in fcurves:
# loop through all keyframes
for kp in fc.keyframe_points:
# change the x (time) value of the keyframe
kp.co.x += offset_amount * i
-
$\begingroup$ This is not working for me, what I forgot to mention is that the animation is happening in a Node (mix shader going from 0 to 1) $\endgroup$– jsprSep 25, 2018 at 13:01
-
1$\begingroup$ @jspr I adjusted the script and the answer. Please include that information in the question, that way other users can search for it with keywords. =) $\endgroup$– LeanderSep 25, 2018 at 13:15