with the recent additions to the sensor logic brick, I thought it might be a good idea to write a documentation regarding pulses. It could be helpful when designing the logic of a game. It is also a good source to check for performance gaps.
You can find it here:
I hope you enjoy
Hey, thanks:yes: alot Monster, that looks very informative, going to take a read of it. Thanks for taking the time to write that man. Also, on this forum I’ve come across many of your thorough responses and blend files with solutions to problems I had, and they’ve helped me alot.
Thanks for being so generous and thoughtful, take care n God bless!
Indeed thanks very much - i had never realised that a FALSE event was dispatched when a sensor stops being triggered. very informative
Thank you monster. Very useful. I had begun to puzzle a little of this out (see my website, below) but i had no idea how complicated it could be.
that’s very nicely documented!
maybe you want to submit your doc to the “official” blender wiki, too?
Thank you very much,
it is good to hear that this wasn’t a wast of time.
The textual part is in the blender wiki already, but I can’t upload the pictures. That’s the reason why I decided to complete it at gameblender.
I want to know what uses there are for these things.
-Fake pulses (also uses if inv. and tap are also selected)
-Fake and True pulses at the same time (also uses if inv. and tap are also selected)
I know how to use True pulses, inv., and tap. I just can’t seem to know of a very good use for the rest of the combinations.
Pulses are used by the standard controllers (AND,OR etc.) to deactivate the connected actuators. E.g. an animation plays (IPO/action in loop stop mode, or motion actuator) as long as you hold a key.
- Press key -> True pulse -> activate actuator
- Hold key -> no pulse -> actuator still active
- Release key -> False pulse -> deactivate actuator
- No key -> no pulse -> activator still deactivated
There is no need to use the True or False pulse modes as the actuators remain active/inactive.
You enable Inv and get the opposite - the animation playes when you NOT press the key.
You enable Tap and you get a one frame animation as the actuator is stopped one logic tick after activation. That could be usefull for stepping e.g you press a key the object makes one step, you press it again = another step etc…
The pulse modes (True/False) are special handy in combination with scripts. As you see the controllers are triggered only when the sensor state changes. The actuators do their work without the controllers as long as they are active. The script controller will run only when the sensor changes from False to True and True to False. This makes exactly 2 script executions. As long as you just activate/deactivate actuators this is fine. But script controllers can also behave like actuators and need pulses for execution.
In a lot of cases you want to execute the script every time the sensor is True. So you activate the True pulse mode -> The script is executed every time as long as the sensor is True.
Example: When holding a key the object should copy the rotation of another object.
The opposite is that you might want to execute the script as long as the sensor is False. Example:
When not holding a key the object should copy the location of another object.
You can argument, that you can achieve this with a combination of other sensors or even with an always sensor in True pulse mode. This is right there are multiple ways.
From logical perspective it is important to understand why a controller is executed and (much more important) why it is not executed. You wonder why your script is not working? Check when it is activated (print can help). You wonder why your script is executed twice but you expect just one run? Beside the True pulse there is always a False pulse (except use the always sensor or you reset the sensor).
From performance perspective a controller should only be executed if it is necessary. Each execution eats time from the logic execution. If the controller does not change anything it is a waste of performance. There were some threads with blends that had bad performance, because they set the same scene again and again at each logic tick etc…
I hope that helps
Very well explained! (:
I was pondering this morning about this very topic… I wonder, is it possible to find out using python which controller sent the pulse? This would be useful for me so I don’t have to split the update script from the controlling when creating click-able lists.
D’oh! Sorry… Followed a link and forgot to read the last post date ):
Don’t worry this is the resource forum. Comments and corrections are always welcome.
To answer your question:
the API is not correct with its description. It must be:
“True if the sensor send a pulse.” or “True if the sensor triggered the controller.”
I prepared a demo file, do you can see it:
sensorDemo.blend (133 KB)
start it, press <space> and/or <left ctrl> and check the console.
I hope it helps
This is exactly what I was hoping for! Thanks heaps Monster!
Very helpful, thanks.
What does Level do? (this may be unrelated)