Vizard 7 » Tutorials & Examples » Avatars » Animating avatars » Tutorial: Smooth moves
7.7

Tutorial: Smooth moves

Thus far our avatars have only been moving in place. Presumably, though, we want them to move forward and have them walk. For example, we might want to use the vizact.walkTo() command to make the male avatar walk over to the female avatar after he is finished dancing. Add the walking code after the dance animation in the heDances() function so that it looks like the following:

    male.addAction( vizact.animation(5) )
    #This line creates an animation in which the male avatar moves
    #to the point (0,0,6).
    walk_over = vizact.walkTo([0,0,6])
    #This line calls that animation
    male.addAction(walk_over)

 

In this example we use the male.addAction() command which causes the Avatar to execute the desired action (See the Using Actions tutorial for further information). Run the script and press 1. The male should complete the two animations, one after the other, dancing and then walking over to the female avatar. Obviously, you can send him anywhere you want by just changing the destination in the walkTo command. Let's pretend the male wants to avoid the female character who's shouting at him. Send the male in the other direction after he waves by replacing the '6' with a '-6':

    walk_over = vizact.walkTo([0,0,-6])

Notice that the walkTo command takes care of turning the male around so that he's facing the direction in which he's moving. You can also smoothly turn an avatar in place with the vizact.turn() command. Comment out the content of the heDances() function by placing '#' symbols in front of the lines within the timer (you can comment all those lines at once by highlighting the lines and hitting Alt-3). Then add the highlighted lines:

    #male.addAction( vizact.animation(5)
    ##This line creates an animation in which the male avatar
    #moves to the point (0,0,6)
    #walk_over = vizact.walkto([0,0,6])
    ##This line calls that animation.
    #male.addAction(walk_over)
    male_turn_around = vizact.turn(90)
    male.addAction(male_turn_around)

Like the walkTo function, these lines create and then call an animation. Run the script and see how the animation smoothly rotates the avatar to the specified number of degrees.

 

For additional examples, check out:

avatar

Adding an avatar

Animating an avatar

Using built-in animations

Using multiple animations

Animating avatar interactions

Smooth moves