How to bring the value of a global variable to a particular value over a period?

0 favourites
  • 4 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi, is there any way I can bring the value of a global variable to a particular value over a period of time? For example, say I have a global variable “A” with a value of 50. On click, I would like to bring this 50 to 35 within a period of 5 seconds.

    I would like this event to be structured in a simplified and reusable manner no matter what destination and time I may determine in the future. For example, instead of bringing it to 35, there might be a point where I may like to bring it to 75 over a period of 10 seconds. Hope someone will be able to guide me on this. Thanks in advance.

  • If I understand you correctly then you can use 2 variables.

    Variable 1 = MainVar

    Variable 2 = ClickVar

    On click

    ClickVar = 0 Wait 5 Seconds

    Set MainVar to 35

    On click

    ClickVar = 1 Wait 10 Seconds

    Set MainVar to 75

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes, This is what I was hoping for. Thanks for the help :)

  • If you want to smoothly transition between the values, you can use the Tween behavior. Create a small, invisible helper sprite and set it to tween value (from a to b, over x seconds). Then have an event If Tween is Playing, set the global variable to its Tween.Value

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)