Bolt - Toggle a button that increases a value over time...

So,

I’m trying to find a way to make a button toggle. I want that button to add a value to a variable every few seconds. ex. Every set amount of time it’ll automatically increase the value by the value that I set while the button is ON.

I’m a beginner so I hope my explanation makes sense. I’ve spend a while now trying to figure this out first with scripts. This is something I’ve seen very little of in idle games.

The two parts to this are: toggling the button on and off, and increasing the value over time.

Thanks!

1 Like

Hello,
You can achieve what you want by following the below steps:

  1. Use the OnToggleValueChange unit to track the toggle value.
  2. Use the Branch unit to check the toggle value. If the toggle value is true then execute the add process.
  3. Use the Add unit to increase the toggle value.

Here is the asset file content

And here is the result

6708805--770914--toggle-increase-value.gif

I pushed the source into this GitHub repository, you can check it out at Assets/Tutorials/ResetNumberByThreshold.
Another way to get help is to join our Discord Server then send your tutorial request to #requests channel in BOLT TIPS & TUTORIALS category.

1 Like