Hi,
The code below will create six avatars and allow the user to click on any of them to cause them to fall down and stay down. Let me know if anything is unclear.
Code:
import viz
viz.go()
avatars = []
#Create six avatars
for i in range(6):
male = viz.add('male.cfg')
male.translate(i,0,0)
male.rotate(180,0,0)
avatars.append(male) #Save avatar in list
def onmousedown(button):
if button == viz.MOUSEBUTTON_LEFT:
node = viz.pick() #Get object that was clicked
if node in avatars: #Check if object is one of the avatars
node.execute(7) #Execute the "shot" animation
#Create action to wait for the animation duration then freeeze the avatar
WaitThenFreeze = vizact.sequence( vizact.waittime(node.getduration(7)-.06), vizact.speed_node(0) )
node.add(WaitThenFreeze) #Add the action to the avatar
viz.callback(viz.MOUSEDOWN_EVENT,onmousedown)
#Move viewpoint so that all avatars are visible
viz.move(2.5,0,-10)
#Disable mouse navigation
viz.mouse(0)