View Single Post
  #2  
Old 09-14-2004, 09:36 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

Currently, the only way to do this is to use the avatar.speed command. When you set the speed of an avatar to 0, it will effectively freeze it.

I wrote a very short script that shows how to do this. Press the spacebar to activate the animation of the avatar being shot. Once the animation is activated, a timer will be set to expire when the animation is over. The timer will then freeze the avatar.
Code:
import viz
viz.go()

FREEZE_AVATAR = 0

male = viz.add('male.cfg')
male.rotate(180,0,0)
viz.move(0,0,-8)

def onkeydown(key):
	if key == ' ':
		#Perform the action
		male.act(7)
		#Start a timer to freeze the avatar when the action is over
		viz.starttimer(FREEZE_AVATAR,male.getduration(7))
		
viz.callback(viz.KEYDOWN_EVENT,onkeydown)


def ontimer(num):
	if num == FREEZE_AVATAR:
		#Freeze the avatar
		male.speed(0)

viz.callback(viz.TIMER_EVENT,ontimer)
Let me know if you need any more help
Reply With Quote