i am a new Python / Blender user from Spain and i am building my first game prototipe.
I Post this thread because i am getting an error using a timer and i don’t know how to solve… i hope somebody here can help me…
I need to control a time interval and i am trying to use a timer… this is my code:
t = Timer(2.0, controlJet)
later i start the timer like this:
t.start()
controlJet is the function i want to call when the 2 seconds has passed… but when i try to make it run i get this error:
NameError: global name ‘Timer’ is not defined
i don’t know how to fix it, i imagine everything is because i don’t import its class, but i don’t know wich one is it, so if somebody could help me please, it would be nice…
better use a timer property as described in the above example (post #2).
The Property Sensor does the evaluation for you. Just check the sensor to be positive.
It’s actually quite easy to do something like this in the BGE.
The easiest way is to use a timer property.
That starts at 0 when the game starts, and continues to count up in quite some accuracy until you end the game, or reset it to 0.
You can use a timer property, and a property sensor.
Set the property sensor to measure an interval from 2 to 2.1
Then, connect it to your module.