PDA

View Full Version : move with avatar and patriot


Veronika
02-27-2012, 12:55 AM
Hello, I have script:
#add avatar
avatar=viz.add('male.cfg')
avatar.state(2)

#Connect to Patriot sensor
polhemus = viz.add('polhemus.dle')
patriot = polhemus.addPatriot()

#set the move and speed
import vizmat
def updateAvatar():
pos=patriot.getPosition()
ori=patriot.getEuler()

p1 = [0,0,0]
p2 = [pos[0],0,pos[0]]
distance = vizmat.Distance(p1,p2)
if distance <= 0.1:
speedFactor = 4
elif distance > 0.1 and distance <= 0.8:
speedFactor = 7
else:
speedFactor = 9

avatar.setPosition([pos[0]*speedFactor,0,pos[0]*speedFactor])
avatar.setEuler([ori[0],0,0])

vizact.onupdate(0,updateAvatar)

But when I move with sensor of Patriot, avatar is moving only in one line, no anywhere in axis x and y.
could you help with this?

Thanks
Veronika

Veronika
02-28-2012, 03:23 AM
I found a mistake :) now it's ok :)