Introdução

Os sensores são os blocos lógicos que fazem com que a lógica possa executar as suas funções. Os sensores fornecem uma saída quando alguma coisa ocorre, por exemplo, a colisão entre dois objetos causa o disparo de um evento, uma tecla pressionada no teclado, ou um temporizador para um evento que possui o tempo contado, pode ser monitorado pelos sensores. Quando um sensor é disparado (ou seja, quando ele recebe o sinal adequado para o seu monitoramento), um pulso positivo é enviado para todos os controladores que estão conectados a ele.

Os blocos lógicos para todos os tipos de sensor podem ser construídos e alterados usando o Editor de lógica podem ser encontrados na página sobre a Edição de sensores.

Common Options

../../../_images/game-engine_logic_sensors_common-options_column3.jpg

Common Sensor options.

All sensors have a set of common buttons, fields and menus. They are organized as follows:

Triangle button
Collapses the sensor information to a single line (toggle).
Sensor type menu
Specifies the type of the sensor.
Sensor name
The name of the sensor. This can be selected by the user. It is used to access sensors with Python; it needs to be unique among the selected objects.
Pin button
Display the sensor even when it is not linked to a visible states controller.
Checkbox button
Sets active state of the sensor.
X button
Deletes the sensor.

Nota

Triggers

If a controller does not get triggered by any connected sensor (regardless of the sensors” state) it will not be activated at all.

A sensor triggers the connected controllers on state change. When the sensor changes its state from negative to positive or positive to negative, the sensor triggers the connected controllers. A sensor triggers a connected controller as well when the sensor changes from deactivation to activation.

The following parameters specify how the sensor triggers connected controllers:

True level triggering
If this is set, the connected controllers will be triggered as long as the sensor’s state is positive. The sensor will trigger with the delay (see parameter: frequency) of the sensor. true-button
False level triggering
If this is set, the connected controllers will be triggered as long as the sensor’s state is negative. The sensor will trigger with the delay (see parameter: frequency) of the sensor. false-button
Freq

Despite its name «Frequency», this parameter sets the delay between repeated triggers, measured in frames (also known as logic ticks). The default value is 0 and it means no delay. It is only used if at least one of the level triggering parameters are enabled.

Raising the value of freq is a good way for saving performance costs by avoiding to execute controllers or activate actuators more often than necessary.

Examples: (assuming the default frame rate with a frequency of 60 Hz (60 frames per second)).

Freq Meaning Frames with trigger Frames without trigger Period in frames Frequency in frames/sec
0 The sensor triggers the next frame. 1 0 1 60
1 The sensor triggers at one frame and waits another one until it triggers again. It results in half speed. 1 1 2 30
29 The sensor triggers at one frame and waits 29 frames until it triggers again. 1 29 30 2
59 The sensor triggers at one frame and waits 59 frames until it triggers again. 1 59 30 1
Level Button
Triggers connected controllers when state (of the build-in state machine) changes (for more information see States).

The following parameters specify how the sensor’s status gets evaluated:

Tap Button
Changes the sensor’s state to negative one frame after changing to positive even if the sensor evaluation remains positive. As this is a state change it triggers the connected controllers as well. Only one of Tap or Level can be activated. If the TRUE level triggering is set, the sensor state will consecutive change from True to False until the sensor evaluates False. The FALSE level triggering will be ignored when the Tap parameter is set.
Invert Button
This inverts the sensor output. If this is set, the sensor’s state will be inverted. This means the sensor’s state changes to positive when evaluating False and changes to False when evaluating True. If the Tap parameter is set, the sensor triggers the controller based on the inverted sensor state.