PDA

View Full Version : multiple timer trouble


exhale
04-25-2005, 01:25 AM
Hello,

I'm having trouble using multiple timers. One is for handling keyboard input to control the viewpoint.

The other is created when a hotspot is entered and is used to move a certain object at a certain rate.

The problem is, when i enter the hotspot, the infinite timer (used for keybcontrol) seems to call the function for moving the object (which is supposed to be run only 100 times), and it does not call the keyboard handling function.

So on entering hotspot, keyboard handling stops, and the object keeps moving. (while it should only do 100 steps).

(btw i used different ID's for both timers)

I included the script as an attachment.

thx in advance,

Kevin

farshizzo
04-25-2005, 10:00 AM
Hi Kevin,

You can only have one function registered with a timer callback at a time. What you will need to do is combine your mytimer and keybcontrols functions to look something like the following:def mytimer(timerNum):
if timerNum == 0:
if viz.iskeydown(viz.KEY_UP):
view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_OR I)
if viz.iskeydown(viz.KEY_DOWN):
view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI)
if viz.iskeydown(viz.KEY_RIGHT):
view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BOD Y_ORI,viz.RELATIVE_WORLD)
if viz.iskeydown(viz.KEY_LEFT):
view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE _WORLD)
elif timerNum == 1:
pos = tbox.get(viz.POSITION)
z = pos[2] - 0.01
print 'z: ', z
tbox.translate(34,0,z)

exhale
04-26-2005, 12:21 AM
Hello,

Ow, so that's how the ID works.
I had tried a few things with it, but hadnt
got it to work.

Thank you a lot!

greets,

Kevin