Pages

segunda-feira, 30 de janeiro de 2017

BP Compendium 3: Do Once

Do Once 


The "Do Once" action performs only once the actions attached to the output pin. After its first run, if the "Do Once" action is performed again, its output pin will not run. To allow the "Do Once" action to execute the output pin again, the "Reset" pin need to be triggered.


Input

  • Reset: Execution pin used to allow "Do Once" to run the output pin.
  • Start Closed: Boolean value. If true indicates that "Do Once" needs to be reset to allow the first run.


Example Usage

Imagine a special weapon that can only be used once per level. This weapon destroys all objects of the "Enemy" class that are currently at the level. The weapon is triggered by pressing the spacebar. After the first execution, even if the space bar is pressed several times, the "Do Once" action prevents the other actions that destroy the enemies from being executed.

Click to enlarge

In another example there is a detonator which generates an explosion when colliding with it. This detonator is controlled by the action "Do Once". The "Start Closed" property is marked indicating that the detonator starts disarmed. The "PrepareDetonator" event needs to be executed to trigger the Reset pin of the "Do Once" action. After this, if there is a collision with the detonator the explosion will be created. To allow a new explosion, the "PrepareDetonator" event needs to be executed  again.

Click to enlarge


Table of Contents