[solved]Get instance variable to trigger function

0 favourites
  • 3 posts
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • Ok so in my game each level has certain requirements to complete the level. I was giving the object that needed to be destroyed/collected an instance variable and when the count reached the appropriate amount trigger the function to call for the level win, but it won't call. Can this only be done with global variables?

    I know that if I make a global variable for the same thing and pass the value into the global variable on destroy/collected instead of the instance, once the right amount has been hit it will trigger the function.

    It just seems like that would be making a lot of global variables for each level complete requirement if there is always going to be a different requirement. Or am I missing a step when calling the function using an instance variable comparison?

    what I'm using now for instance variable function call:

    I do have it set to add to the instance variable here:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The problem is that the instance, and, thus, the instance variable, is destroyed. So it ceases to exist BEFORE being increased.

    You don't have to have lots of global variables to do that. Just have two: totalDestroyed, which will be zeroed at the start of every level, to record every time you destroy a ship; and a requiredDestroyed, which will be the amount of ships you need to destroy to finish a level and will be set at the begining of every level to the corresponding target number.

    Hope this helps. Cheers!

  • brunopalermo yep that helps and makes sense, thanks.

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