Search Unity

Resolved how to increment variable by 1 using bolt

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

  1. White-studio

    White-studio

    Joined:
    May 1, 2013
    Posts:
    7
    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

    Ex-Crow

    Joined:
    Aug 14, 2020
    Posts:
    111
    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
    Streamfall and jlopez_unity890 like this.
  3. faheemaries

    faheemaries

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