Here is a step-by-step guide on how you can add coins/collectables to your game.
Place down a barrier. This will be your coin. Set Active Scope to “player”, Collision Enabled to “No”.
Set Barrier Shape to “Circle” and resize to however you want.
Place down a trigger. Set Visible In Game to “No”, Active Scope to “player”, Max Triggers to “1” (depends on how many times you want the player to collect a coin.)
Place your coin (barrier) on/in your trigger.
Place down a property. Name it to “coins”. Set Property Type to “Number”, Property Scope to “player”.
Place down a counter, set Visible In Game to “No”, Count Scope to “player”.
Go to the Property tab, set Update Property to “Yes”, Property To Update to “coins”.
Go back and select the trigger. “When triggered, transmit on” set to “coins”.
Go back to the counter. “Increment counter when receiving on” set to “coins”.
This is what you should have so far:
Go to test the game, and you see the coins property update when you touch the coin.
You may notice that the coin doesn’t disappear when you touch it. To fix this, just wire the trigger with the barrier: Triggered > Deactivate barrier (you have to do this for all your coins).
To let the players track how many coins they have, we need an overlay. Place an overlay down.
Set Overlay type to “Text”, Content Scope and Visibility Scope to “player”.
Go to blocks > When receiving on channel “coins”.
Follow this code:
If you want fix the “s” in “coins”, follow this code below:
And now it shoukd update the coins whenever you collect one!