0
$\begingroup$

I'm animating a model (a lightsaber) and I want the blade to ignate. I found a method that uses the shrinkwrap modifier but I don't know how to code it with python. This is the animation with the shrinkwrap value= 1.0 enter image description here

And this is the animation with the shrinkwrap value= 0.0 enter image description here It's kind of difficult to me to explain, but basically is adding keyframes and each keyframe added needs to have a different shrinkwrap value. I'm also open to other methods, but I need to code the animation.

This is what I have so far:

import bpy

lightsaber = bpy.data.objects['Lightsaber']

lightsaber.keyframe_insert(data_path='location', frame=1)
lightsaber.keyframe_insert(data_path='location', frame=4)
lightsaber.keyframe_insert(data_path='location', frame=10)

Thank you.

$\endgroup$

1 Answer 1

1
$\begingroup$

Your "shrinkwrap" is a shape key.

You have to access it through the object data, in the shape_keys part and get the key_block by its name (or index).

That can be:

import bpy


#Get the object
lightsaber = bpy.data.objects['Lightsaber']

#Get the shape key
shrinkwrap = lightsaber.data.shape_keys.key_blocks['Shrinkwrap']

#Assign values and insert keyframes on it

shrinkwrap.value = 1
shrinkwrap.keyframe_insert("value", frame = 0)

shrinkwrap.value = 0
shrinkwrap.keyframe_insert("value", frame = 50)
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .