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)