View Single Post
  #2  
Old 02-13-2009, 09:45 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You should be able to use the bone.lookat command to have the head face a certain position. Here is a sample script:
Code:
import viz
import vizact
viz.go()

viz.add('tut_ground.wrl')

#Create animating ball
ball = viz.add('white_ball.wrl')
ball.add(vizact.sequence(vizact.goto(-2,1,0),vizact.goto(2,1,0),viz.FOREVER))

#Create male avatar
avatar1 = viz.add('vcc_male.cfg',pos=(-2,0,3),euler=(180,0,0))
avatar1.state(1)
head1 = avatar1.getBone('Bip01 Head')
head1.lock()

#Create female avatar
avatar2 = viz.add('vcc_female.cfg',pos=(2,0,3),euler=(180,0,0))
avatar2.state(1)
head2 = avatar2.getBone('Bip01 Head')
head2.lock()

def UpdateAvatarHead():
	"""Update avatars to look at ball position"""
	pos = ball.getPosition()
	
	head1.lookat(pos,0,viz.AVATAR_WORLD)
	head2.lookat(pos,0,viz.AVATAR_WORLD)

vizact.ontimer(0,UpdateAvatarHead)

viz.MainView.move(0,0,-5)
Reply With Quote