From BlenderWiki

Jump to: navigation, search

If you want to document Blender 2.5 features please edit pages under Doc:2.5/Manual.
If a "2.5" page doesn't exist please copy the text from 2.4x Manual and edit the new page (i.e. you should paste the wikitext from this 2.4x page to this new 2.5x page and then update the latter with 2.5 features)


[edit] Sensors

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.

[edit] 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.


[edit] General object options

Object before adding a sensor

All objects have two buttons, one which is labeled with their name, and the other labeled Add.

Object after adding a sensor

The Add button adds a new sensor to the object.

Object with sensors collapsed

The button with the object’s name is for collapsing the object list and hiding its sensors.

Object after deleting all sensors

An object without sensors is automatically collapsed. Adding a sensor will automatically show the object.

[edit] 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.

[edit] Sensor header

Sensor header
Cross button
deletes the sensor.
Sensor type menu
see sensor types below.
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.


[edit] 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.

Sensor pulses bar
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.
Level
Makes the sensor working over state changes. See this page for the state system.
Tap
Sends a positive pulse only once even if the sensor remains true. Only one of Tap or Level can be activated at the same time.
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.
Inv
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.


Start the game and and don't press W: in the debug info you should see the "click" property running, changing every 15 ticks (a quarter of a second). This is because the sensor is FALSE but it is inverted to TRUE with Inv, hence the True level trigger is pulsing.


GameLogic python API.



[edit] Subpages

  1. Types