Sensors are the causes of logic to do anything. This can be a trigger event such as a nearby object, a key pressed on the keyboard, timed events, etc. When a sensor is triggered, a positive pulse is sent to all controllers that are linked to it.
Sensor viewing options
Blender sensors can be found in the Logic Panel. At the top of the Sensors sub-panel, there are four buttons labeled Sel, Act, Link and State. There is also a menu that is activated by clicking Sensors, the title of the sensor sub-panel. This is for showing/hiding sensors and is very useful so unneeded sensors can be hidden and the necessary ones visible and easier to reach. Sensors are grouped by object with every selected object appearing in a list and under each object are it's sensors.
The menu labeled Sensors looks like a label but is a menu. It has four options:
- Show Objects expands all objects.
- Hide Objects collapses all objects to just a bar with their name.
- Show Sensors expands all sensors.
- Hide Sensors collapses all sensors to bars with their names.
Both these can be controlled individually on the sensor or object.
It is also possible to filter which sensors are viewed:
- Sel shows all selected objects sensors.
- Act shows only active objects sensors.
- Link shows sensors which have a link to a controller.
- State: only sensors connected to a controller of the current state are shown.
General object options
All objects have two buttons, one which is labeled with their name, and the other labeled Add.
The Add button adds a new sensor to the object.
The button with the object’s name is for collapsing the object list and hiding its sensors.
An object without sensors is automatically collapsed. Adding a sensor will automatically show the object.
General sensor options
All sensors have a set of buttons and fields and menu in common. They are organized in the two rows: the sensor header and the sensor pulses bar.
- Cross button
- deletes the sensor.
- Sensor type menu
- see sensor types.
- Sensor name
- the name of the sensor. It is used to access sensors with python; it needs to be unique among the selected objects.
- Triangle button
- used for collapsing the sensor.
Sensor pulses bar
Sensors fire pulses to controllers. The pulses can be TRUE or FALSE. Different parameters on the sensor's logic block control when a sensor fires what pulse. This is extremly important as it has direct influence on the game logic and the performance. It is up to the controllers how to react on TRUE and FALSE pulses.
- True level triggering
- If this is set, the controllers receive TRUE pulses as long as the sensor's state is positive. The sensor will fire TRUE pulses with the frequency of the sensor.
- False level triggering
- If this is set, the controllers receive FALSE pulses as long as the sensor's state is negative. The sensor will fire FALSE pulses with the frequency of the sensor.
Note about triggers
If you don't set any triggers, the sensor fires no pulse at all as long the sensor's state does not change. When the sensor changes it's state from negative to positive the sensor fires one TRUE pulse to the controllers. When sensor changes it's state from positive to negative the sensor fires one FALSE pulse to the controllers.
In between the controllers might still request the sensor's state, but if the controller does not get pulses (TRUE or FALSE) from any other sensor it will not be activated at all.
- Frequency (f)
- Despite the name, "Frequency", the f parameter sets the delay between repeated pulses, measured in logic ticks. The default value is 0 and it means no delay.
- Logic ticks have a frequency of 60 Hz (60 ticks per second). For example:
- setting f=1 means the sensor pulses once every 60th of a second. A setting of f = 1, effectively means a 1 to 1 ratio between ticks, 1 tick = 1 pulse.
- setting f=30 means the sensor pulses once after 30 ticks have elapsed. This means the pulse is emitted every half a second because there are 60 ticks per second by default.
- setting f=60 means the sensor pulses every 60 ticks, which means one time per second
- Raising the value of f is good for saving performance by not doing things more often than necessary.
- Makes the sensor working over state changes. See this page for the state system.
- Sends a positive pulse only once even if the sensor remains true. Only one of Tap or Level can be activated.
- When the Tap parameter is set the sensor will fire a FALSE pulse within the next frame, even when the sensor event is still present. When the sensor's event goes away no pulse will be fired.
- If the TRUE level triggering is set, the TRUE/FALSE pulse pair will be repeated until the sensor's event goes away.
- The FALSE level triggering will be ignored when the Tap parameter is set.
- Pulses will not be inverted when the Inv parameter is set. But the TRUE/FALSE pulse pair will be send when the sensor's event is not present.
- This inverts the sensor output.
- If this is set, the sensor will send FALSE pulses when the sensor should send TRUE pulses and TRUE pulses if the sensor should send FALSE pulses. If the Tap parameter is set, the sensor acts different (refer to the previous section).
Note about Inv and triggers
Note that the toggle Inv inverts the level BEFORE the triggers, which means the triggers act on the signal coming out from Inv.
As a test, setup the logic bricks as below on an object of your choice.
Inv, hence the True level trigger is pulsing.