Timer Actions problem
Hello,
I wrote a small script basically want to play some animation paths in a specific schedule and every animation path can be played more than once. In this script, I create an animation path for a ball and another animation path for a duck. The array time_to_go[] and object[] make a schedule for the ball and duck. Here I would like firstly duck start to move; and after 3 seconds, ball start to move; and after another 3 seconds, ball start to move again. Then done. unfortunately the ball will start the 3rd time after my schedule. Could somebody help me diagnose what's wrong with it. Thanks, Code:
import viz |
Seems like I can play a lot of animation paths in a specific schedule, but every animation path can be played only once. Otherwise it would be messed up. Any hint?
|
It looks like you are creating 2 vizact.ontimer2 objects for the ball when you only need one that repeats once. Try changing the 3 to a 2 in this for loop
Code:
#Create an array of timer action |
Hi,
I think the 3 is actually len(time_to_go) or len(object). Because I define 3 events. I just put "donothing" as the first event (for duck action), and put ball actions as the 2nd and the 3rd event. Thanks, Haojie |
Seems to me that the array of myTimerAction got initialized correctly, but after path[x].pause() and path[x].reset(), the animation path were messed up. Any suggestion?
|
This code loops three times
Code:
object = [1, 0, 0] #1 means duck, 0 means ball |
I don't understand that "a timer object is created that will repeat one time, so the ball's path will be played twice." Why will it REPEAT one time? I thought the ball should be play only two times in a total. How do you suggest to change my reset code?
Thanks a lot! |
Because you have repeats set to 1 this timer will be called twice and the path will be played twice.
Code:
vizact.ontimer2(wait, 1, path[object[x]].play) |
Oh!!! I always thought the second argument of vizact.ontimer2 was the number of times to active the timer. Sorry about that. I should set it to 0. I'll correct it and see what happened....
Thanks a lot! |
Thank you, Jeff. It works!
Now I make a little change on the reset part. I would like to reset the object (duck or ball) right before being played. But I got the following error: Traceback (most recent call last): File "C:\Program Files\WorldViz\Vizard30/python\vizact.py", line 2980, in __ontimer val = event.call() File "C:\Program Files\WorldViz\Vizard30/python\vizact.py", line 2803, in _callStatic return self.func(*self.args,**self.kwargs) TypeError: 'NoneType' object is not callable Could you please help me find the problem again? Thanks! Code:
import viz |
The error is in this line
Code:
vizact.ontimer2(wait, 0, reset(object[x])) Code:
vizact.ontimer2(wait, 0, reset, object[x]) |
Thank you so much for your help, especially at weekend. :)
|
All times are GMT -7. The time now is 07:07 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC