#1
|
|||
|
|||
multiple timer trouble
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 |
#2
|
|||
|
|||
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: Code:
def mytimer(timerNum): if timerNum == 0: if viz.iskeydown(viz.KEY_UP): view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_ORI) 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.BODY_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) |
#3
|
|||
|
|||
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 |
|
|