Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Resolved how to increment variable by 1 using bolt

Discussion in 'Visual Scripting' started by White-studio, Oct 14, 2020.

  1. White-studio


    May 1, 2013
    Right this is what I am currently doing, below I will try and describe it clearly, cant include the flow graph, because I am a useless and it is needlessly large so wont fit.

    I have a timer which lasts for 1 second then it updates a variable called one second timer with the value

    when the one second timer variable updates, i have an if statement which checks if the one second timer variable is equals to one, if it is then i want the Seconds elapsed since start variable to be incremented by one.

    when the seconds elapsed since start reach 60, i have another if statement which does the same thing again but this time it increments the minutes elapsed since start variable by one.

    i am programming my own skybox in bolt and this is so I can keep track of the amount of time that has elapsed since the game has been started, i know that there are probably more intelligent ways of doing it, but i have only just started and this is the only way I could think of doing it.

    it is relatively simple in programming, although I cant programme at all using the csharp language there are plenty of resources online which show you how to do it, but in bolt I haven't seen a single mention of increment at all, I am currently searching through all of YouTube to try and see if anyone just happens to do this in there tutorials, thank you in advanced
  2. Ex-Crow


    Aug 14, 2020
    Bolt doesn't have a native increment operator at this moment in time. So what you do is this:

    1. Get current variable value with Get Variable unit
    2. Use scalar Add unit to add + 1 to current variable value
    3. Wire the Add value output to a Set Variable unit

    Get Variable X --> Add +1 to variable X --> Set Variable X.
    Last edited: Oct 15, 2020
  3. faheemaries


    Jan 10, 2018
    Code (CSharp):
    2. void update
    3. {
    4. variable++;
    5. }