expressions and sensitivity

I have a menu setup, where I click a button and it will switch to the next object. However, when I click that button, it changes to the next a couple times as opposed to the single time that I would like.

The sensor is a message sensor, listening for the command, and the controller is an expression, which says “if value is less than the max”. How can I change this to only change to the next object once?

If it’s something obvious, sorry, I’m fairly new to the Blender game engine, and have little understanding of how the expression controller works.

Here is the file: custom ship.blend (194 KB)

Basically, the overlay scene has the controls and messages the other scene, which has the main content, and the controllers in question, which are on the “body” object. (the same thing is happening with the button between the arrows in the overlay)

Help is appreciated

It’s NOT obvious. It’s downright counter-intuitive. Dragging from a sensor to a controller does NOT guarantee that the controller will be dormant when the sensor is false. Don’t know why this is, but there you have it.

Therefore, your expression must also confirm the truth of the sensor, lest it fire multiple times. Let’s assume you have a message sensor called “listennext” (note the lack of spaces), and wanted to fire the actuator only if property “body” < 3, when listennext detected a message. This would be your expression:

listennext and body < 3

It tests for both the truth of the sensor AND the criteria you want. Without the sensor check, you’ll get multiple firings to the controller whilst the sensor is still false. Weird, but true :slight_smile:

Thanks, that helped me fix it :slight_smile: