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)
The f parameter sets the frequency of the sensor, which is the delay between repeated pulses, measured in logic ticks (default is 0 and means no delay).
This 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
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).

GameLogic python API.

[edit] Sensor types

[edit] Always sensor

The Always sensor is used for things that need to be done every logic tick, or at every x logic tick (with non-null f), or at start-up (with Tap).

This sensor doesn’t have any options apart from the general sensor ones.

GameLogic python API.

[edit] Delay sensor

The Delay sensor is designed for delaying reactions a number of logic ticks. This is useful if an other action has to be done first or to time events.

The Delay sensor has three options:

  • Delay is the number of logic ticks the sensor waits before sending a positive pulse.
  • Duration is the time the sensor waits before sending the negative pulse.
  • Repeats makes the sensor restart after the delay and duration time is up.

GameLogic python API.

[edit] Keyboard sensor

The Keyboard sensor is for detecting keyboard input, it can also save keyboard input to a String property.

The first row of buttons (Key one) is for single key presses. Press the button with no label and a key to assign that key to the sensor. This is the active key, which will trigger the positive pulse. Click the button and then click outside of the button to deassign the key. The All keys button will hide all other button and send positive pulses on all key presses. This is useful for custom key maps with a Python controller.

The Hold buttons work the same way as the key button but won’t set off a positive pulse unless hold down while the key button is pressed. You can have up to two of hold buttons. If a key is assigned here, a positive pulse won’t be send unless both/all keys are pressed. This is useful if you wish to have for example CtrlR or ⇧ ShiftAltEsc to do a specific action.

LogToggle field assigns a Bool property which determines if the keystroke will be logged in the String property (true) or not (false). This needs to be here if you wish to log your keystrokes.

Target is the String property to which the keystrokes are saved. Together with a Property sensor this can be used for example to enter passwords.

GameLogic python API.

[edit] Mouse sensor

The Mouse sensor is for detecting mouse input. The controller consist only of a list of types of mouse events. These are:

  • Left button.
  • Middle button.
  • Right button
  • Wheel Up, the scroll wheel of the mouse.
  • Wheel Down, the scroll wheel of the mouse.
  • Movement, any movement with the mouse.
  • Mouse over, detects if the mouse is over the object.
  • Mouse over any, detects if the mouse is over any object.

There is no logic brick for specific mouse movement and reactions (such as first person camera), these has to be coded in python.

GameLogic python API.

[edit] Touch sensor

The Touch sensor sends a positive pulse when the object is in contact with another object. The MA field is for filtering materials. Only contact with the material in this field will generate a positive pulse. Leave blank for touch with any object. The positive pulse is sent on collision and the negative pulse is sent once the objects are no longer in contact. For a continuous pulse while they are in contact use “True Pulse triggering”.

GameLogic python API.

[edit] Collision sensor

A Collision sensor works like a Touch sensor but can also filter by property. Only objects with the property with that name will generate a positive pulse upon collision. Leave blank for collision with any object.

The Pulse button makes it sensible to other collisions even if it is still in touch with the object that triggered the last positive pulse.

The M/P button toggles between material and property filtering.

[edit] Near sensor

A Near sensor detects objects that are within a specific distance of themselves. It can filter objects with properties, like the Collision sensor.

Distance is the number of blender units it will detect objects within. Reset is the distance the object needs to be to reset the sensor (send a negative pulse).

GameLogic python API.

[edit] Radar sensor

A Radar sensor works much like a Near sensor, but only within an angle from an axis, forming an invisible cone with the top in the objects’ centre and base at a distance on an axis. It has a property filter field (Prop). Next to it is the axis menu, which determines the direction of the radar cone. The ± signs is whether it is on the axis direction (+), or the opposite (-).

Angle determines the width of the cone, and Distance its length.

This sensor is useful for giving bots sight only in front of them, for example. Note that it does see through other objects.

GameLogic python API.

[edit] Property sensor

The Property sensor detect changes in the objects properties. This sensor has four modes:

  • Equal triggers a positive pulse when the property value matches the value in the sensor. The Prop field is for the name of the property, and Value is for the value it has to match to send a positive pulse.
  • Not Equal triggers a positive pulse when the property value differs from the value in the sensor. The same fields as Equal, but Value represents the value the property has to differ from in order to set off a pulse.
  • Interval triggers a positive pulse when the value of the property is between the Min and Max values of the sensor. For “more than”, enter the property name in the Max field and the lowest number for triggering in the Min field. For “less than”, enter the property name in the Min field and the maximum value in the Max field. Names of other properties can also be entered to compare properties.
  • Changed sends a positive pulse as soon as the property value changes.

GameLogic python API.

[edit] Random sensor

The Random sensor generates random pulses. It has a Seed field to enter the initial seed. 0 is not random, for testing and debugging purposes.

GameLogic python API.

[edit] Ray sensor

The Ray sensor shoots a ray in the direction of an axis and sends a positive pulse once it hits something. It can be filtered to only detect objects with a given material or property.

It shares a lot of buttons and fields with Radar sensor. The X button make it x-ray, it sees through objects that doesn’t have the property or material specified in the filter field.

GameLogic python API.

[edit] Message sensor

Messages can be used to send either text or property values. The Message sensor sends a positive pulse once a message is sent anywhere in the engine. It can filter to only send a pulse upon a message with a specific subject.

GameLogic python API.

[edit] Joystick sensor

The Joystick sensor detect joystick events.

GameLogic python API.

[edit] Actuator sensor

The Actuator sensor is set off when an actuator with the name specified in the Act field is activated.

GameLogic python API.





Redirects to fix

  • Doc:Manual/Game Engine/Logic/Sensors/Sensor pulses →

    %DPL-1.7.4-WARNING: No results!