Search Unity

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

Discussion in 'Visual Scripting' started by soupypunk, Jan 10, 2021.

  1. soupypunk

    soupypunk

    Joined:
    Jan 10, 2021
    Posts:
    3
    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!
     
    yolostudio likes this.
  2. yolostudio

    yolostudio

    Joined:
    Aug 20, 2020
    Posts:
    10
    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

    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.
     

    Attached Files:

    ghdenrjs likes this.