|Name of gadget||Counter|
|Section||Logic & Processing|
|Last updated||22 Feb 2019 [Beta]|
Counts up to a given target value (or down from it) and sends a signal when it is full. This is used in combination with other gadgets (such as the timer and the calculator) and is especially useful for taking a pulse and producing a continuous signal (such as a button press). Any signal sent to the increase or decrease inputs will cause the counter to count up or down once, respectively, regardless of whether it is the shortest pulse or a prolonged button press.
Example Tutorial (adapted from Media Molecule)
- Stamp a counter
- Stamp a trigger zone
- Stamp a sound effect
- Stamp a basic puppet
- Connect detected on the trigger zone to increase count on the counter.
- The default maximum in the counter is 1. When the trigger zone is activated it will fill the counter. Connect Counter full to the power port on the sound effect.
- Play the level.
- Possess the puppet and run into the trigger zone.
- The sound effect should play.
- Now tweak the counter to set the maximum to 5.
- Play again, and this time note that the player has to enter the trigger zone 5 times before the sound effect is activated.
- Target Value
Use the slider to determine how many this counter will count to (determine the full amount). The default is 1.You can alter this dynamically with the input, and the target value can be sent as a signal from the output.
- Current Count
This slider shows the current value of the counter, up to the target value. You can set this so that the counter starts at a number that is not the default 0. The number can be sent as a signal from the output.
- Counter Full
This is the main output of the gadget. A signal of 1 is sent when the counter is full, a 0 for any other amount. It ignores any additional counts past the maximum set in the gadget and continues to send 1 regardless of the actual count (unless the count reduces).
- Count Progress
As an alternative to the “Current Count” output, this provides the current status of the counter as a fractional output, from 0 (zero) to 1 (target value). If you are building an on-screen display, for example, that indicates percentage completion, you should use this output because it will always range from 0 to 1, whereas the Current Count’s range might change as you add new objectives to your Dream.
- Increase Count
Wire into here to add to the current counter value (for example from the controller sensor).
- Decrease Count
Wire into here to reduce the current counter value.
- Reset Count
This will set the count back to zero. You can wire the Counter Full output back into the reset for a continuous loop.
This is where you can turn the gadget on/off
A very useful gadget that you may use quite a lot. Use this to determine if an action has completed so that you set other actions in motion. Don’t forget to name your counter so you know what it is counting. Can also act as a boolean if you keep the number at 0 or 1 (though a Switch may be a better solution). Reset to get back to 0.
I can’t stress enough how important this gadget is for firing off ‘events’ in your Dream that should happen once and only once. I can’t count (no pun intended) the number of times I’ve had to sit through the same cut-scene or text pop-up or sound effect multiple times when the creator only meant for it to happen once. In the worst cases, players can rack up impossible scores by repeating an action they were only meant to do one time, like crossing the finish line in a race, if your logic doesn’t account for them doubling back and doing it again.
If you ever plan for something to happen once, or for it to be different the first time, always think to yourself: “I need a counter”. The first time that something happens, the counter is 0, which, with the right logic, can be made to allow action to take place, at which point you increment the counter and it is now fixed on 1, which you can use to prevent the action triggering again.