0 Favourites

Set Global Var Value to Value of another Global?

  • Hi!

    First post here so here goes....

    I have a global variable that represents the score for the game and on every tick it counts down a set amount. When the player reaches the end of the game I have a collision event that ends the level. What I want to do then is take the value stored in the global score variable ( that is being subtracted every tick ) and set it to another global variable for the final score before ending the level. So to summarize I am trying to set the value of one global variable to another global variable, is this possible?

    I am in a time crunch at the moment so any immediate feedback is welcome!

    Thank you in advance!

  • Follow up....

    Or another way is how can I stop the subtraction of a value on collision with another object? I hope this makes sense.

    Thanks again!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You could use a triggered event with a second global variable, so on the ending collision event you'd use "System>Variables>Set Value" and it'd look something like "2nd variable = 1st variable". Your second variable isn't counting down as it was triggered once. There's a much better way of doing this though. You can set up a function that will decrement the main score as long as you are in a 'play' state. When you collide and finish the level, change the state of your game to 'end', and since this will stop the score from decrementing, you can apply the score just from the one variable wherever you'd like (high scores table, text/dialog box, database, etc.) Good luck!

    Paul

  • Awesome! Thanks for the quick reply!

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