Vizard 7 » Tutorials & Examples » Avatars » Animating avatars » Tutorial: Using multiple animations
7.7

Tutorial: Using multiple animations

Sometimes you might want your avatars to do multiple things at once. For example, you might want your male avatar to walk and pick something up at the same time. To do this, we can blend two animations together with the blend command. Add the following function to perform the blend and a  vizact.onkeydown that registers this function with key "6".

#blend two animations
def blendAnimations():

    male.blend(2, .5)
    male.blend(10, .5)

vizact.onkeydown('6', blendAnimations)

Run the script again and see how these lines blend walking (animation #2) and pickup (animation #10). Within the blend command, the first parameter refers to a specific animation and the second parameter refers to the proportion of that animation's contribution to the blend. If your avatar really needs to interact with your world, you might want him to do use more items and less walking. In this case, simply bump up the items proportion to .8 and reduce the walking proportion to .2 (as highlighted below):

    male.blend(2, .2)
    male.blend(10, .8)

Now maybe you don't want your avatar to do two things at once.  In that case, we can interject an animation into the avatar's sequence with the execute command. Do that with the following code:

#execute a single animation that does not repeat
vizact.onkeydown('7', male.execute, 6)

Run the script again. First press 2 to get the avatar walking, and then press 7 and notice how the avatar stops walking, executes, and then resumes his walking state. To stop the avatar from walking, we use the stopAnimation command for that specific animation (in this case, animation #2):

#stop an animation
vizact.onkeydown('8', male.stopAnimation, 2)

Run the script again to get the avatar walking with the 2 or the 6 key, and then hit the 8 key to make him stop walking.

For additional examples, check out:

avatar

Adding an avatar

Animating an avatar

Using built-in animations

Using multiple animations

Animating avatar interactions

Smooth moves