# How to suspend object's logic in BGE?

I want to save performance in a scene which contains a lot of objects with constantly working logic bricks. How to turn it off while the player is not nearby?

You can do it with logic bricks:

Explanation: This logic setting will suspend physics (Edit Object brick/Dynamics/Suspend Dynamics) at the beginning of the game (Delay = 0) and restore it (Edit Object brick/Dynamics/Restore Dynamics) when an object with a player property is in a 5 blender units distance.

• I deleted my example, this is a much cleaner solution. – dval Jan 15 '16 at 2:46
• Also, I believe These are referred to as 'Logic Bricks' in the Logic editor, not Nodes. This might cause confusion with the 'Node Editor' window. [blender.org/manual/game_engine/logic/… – dval Jan 15 '16 at 4:32
• @dval you are right I updated the answer. Thanks – atevm Jan 15 '16 at 8:19

Lets talk a bit about when logic bricks run

# Sensors

Sensors will always run when they have a connection to an enabled controller. A controller is enabled when it belongs to an active state of the game object.

This means you can dynamically disable sensors by switching the state.

Warning: Disabled sensors do not sense anything. They will start sensing within the next frame after enabling them.

# Controllers

Controllers are executed when they get at least one trigger from any connected sensor. Therefore the most inefficient design is to use an Always sensor with [True Level Triggering] enabled. Therefore avoid that unless it is absolutely necessary.

# Actuators

Actuators run when they are active. They react on activation and deactivation signals from connected controllers. Activation signals override deactivation signals (OR behavior).

Actuators differ in how long they run.

## Single Frame Run

These actuators run exactly one frame and deactivate themselves. They will ignore deactivation signals as they have no effect anyway.

Examples: * Property Actuator, Action Actuator in Property Mode, Random Actuator, Scene Actuator

## Autodeactivation

These actuators perform there operation until it completes. Examples: * Action Actuator Play mode

## Explicit deactivation

These Actuator run unto they get a deactivation signal Examples: * Action Actuator Loop Stop Mode * Motion Actuator

Sometimes they continue but stop at a later time. Examples: * Action Actuator Loop End Mode (stops when the cycle completed) * Action Actuator Flipper mode (stops after finishing the reverse playback)

### Hint:

• You can measure if an actuator is running or not with the Actuator sensor (be aware at startup no actuator runs).

# Conclusion:

It is up to you to choose an efficient design. Anything that does not run ... eats less time.

# Turning off logic that is not near the player

First of all you need an efficient way to identify such objects. Then you can

• Remove the game object
• Switch states to disable sensors

but you need the other way around too. When the (supposed) object comes near: