Skip to main content
edited tags; edited title
Link
lemon
  • 60.8k
  • 3
  • 68
  • 141

Need help with writing a code How to add keyframes and change the shape key (named shrinkwrap) value of the objectwith Python?

Source Link

Need help with writing a code to add keyframes and change the shrinkwrap value of the object

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.