We'll blend two animations together to see how this works.
Open
Anim_01.py
in theChapter09
folder.We need to load a second animation to be able to blend. Change the line where we create our
Actor
to look like the following code:self.kid = Actor("../Models/Kid.egg", {"Walk" : "../Animations/Walk.egg", "Thoughtful" : "../Animations/Thoughtful.egg"})
Now, we just need to add this code above the line where we start looping the
Walk
animation:self.kid.enableBlend() self.kid.setControlEffect("Walk", 1) self.kid.setControlEffect("Thoughtful", 1)
Resave the file as
Anim_02.py
and run it from the command prompt.
Our Actor
is now performing both animations to their full extent at the same time. This is possible because we made the call to the self.kid.enableBlend()
method and then set the amount of effect each animation would have on the model with the self.kid.setControlEffect()
method. We can turn off blending...