WorldViz User Forum Problem with getting duration of walkto()
 Register FAQ Search Today's Posts Mark Forums Read

#1
03-21-2007, 03:59 AM
 ghazanfar Member Join Date: Mar 2007 Posts: 11
Problem with getting duration of walkto()

We are trying to let avatars walk to each other, after that face to each other and wave (say hello).

We have a problem with letting the avatars face to each other, because deciding which angle they have to rotate happens before the agents are done walking.

Does anyone know how to get the duration of walking to a certain point, so we can get the angle to rotate after the walking has finished? Or just letting the program wait until the walking has finished and the continue?

Our current code is the following:

if (ag1=='a1' and ag2=='a3'):
walk_over = male.walkto(meetingpoint[0]+1,meetingpoint[1],meetingpoint[2])
#This line calls that animation.
male.act(walk_over)

#THIS IS WHAT WE HAVE TRIED UNTIL NOW
#male_wave_duration = male.getduration(walk_over)
malepd=male.getduration(5) # THIS WORKS
print "malepd", malepd
#malewd2=male.getduration(walkto)
#print "malewd2", malewd2 # THIS RETURNS AN ERROR
malewd=male.getduration(male.walkto)
print "malewd", malewd # THIS RETURNS AN ERROR
#viz.starttimer(1,malewd )
#print "male_wave_duration", malewd

pos=male.get(viz.POSITION)
pos2=male1.get(viz.POSITION)
rotate_degrees = vizmat.AngleToPoint(pos[0],pos[2],pos2[0],pos2[2])
male.rotate(0,1,0,rotate_degrees)
male.act(5)
walk_over2 = male1.walkto(meetingpoint[0],meetingpoint[1],meetingpoint[2])
male1.act(walk_over2)
pos=male1.get(viz.POSITION)
pos2=male.get(viz.POSITION)
rotate_degrees = vizmat.AngleToPoint(pos[0],pos[2],pos2[0],pos2[2])
male1.rotate(0,1,0,rotate_degrees)
male1.act(5)
#2
03-21-2007, 01:00 PM
 farshizzo WorldViz Team Member Join Date: Mar 2003 Posts: 2,849
The <avatar>.getduration() function returns the duration of built-in animations, not actions. There is no way to get the duration of an action, but you can register a callback to notify you when an action is finished. Here is some sample code:
Code:
```import viz
viz.go()

walk = vizact.walkto(0,0,10)

def onActionEnd(obj,action,pool):
if obj == male and action == walk:
print 'Male finished walking'
viz.clearcolor(viz.SKYBLUE)
viz.callback(viz.ACTION_END_EVENT,onActionEnd)```
#3
03-22-2007, 09:17 AM
 ghazanfar Member Join Date: Mar 2007 Posts: 11
Do you know how to send a value for 'pool' to the onActionEnd function?

We are trying to use the function in this function:

if (ag1=='a1' and ag2=='a3'):
walk_over = male.walkto(meetingpoint[0]+1,meetingpoint[1],meetingpoint[2])
#This line calls that animation.
male.act(walk_over)
walk_over2 = male1.walkto(meetingpoint[0],meetingpoint[1],meetingpoint[2])
male1.act(walk_over2)
viz.callback(viz.ACTION_END_EVENT,onActionEnd)

And the onActionEnd function currently looks like this:

def onActionEnd(obj,action,pool):
if obj == male and action == walk and pool == malemale1:
pos=male.get(viz.POSITION)
pos2=male1.get(viz.POSITION)
rotate_degrees = vizmat.AngleToPoint(pos[0],pos[2],pos2[0],pos2[2])
male.rotate(0,1,0,rotate_degrees)
male.act(5)
#4
03-22-2007, 10:22 AM
 farshizzo WorldViz Team Member Join Date: Mar 2003 Posts: 2,849
You probably won't need to worry about the pool parameter. When you add an action, you can specify a pool number. This allows you to execute actions in parallel by adding them to different pools. The default pool is 0.
#5
03-23-2007, 09:17 AM
 ghazanfar Member Join Date: Mar 2007 Posts: 11
OK thanks we understand this function now.
We have decided to solve our problem otherwise.

We created a timer that would count every step, and every 5 steps the next step would be done. This way, we could say that the avatar had to turn 3 steps after the walking action, and also give the other avatar to turn to as a variable.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements Vizard Precision Position Tracker (PPT) Plug-in development

All times are GMT -7. The time now is 06:08 PM.