How do I add up a total for all instances of a sprite in a given map zone?

0 favourites
  • 5 posts
From the Asset Store
Two types of minimap: "full map" and "player is the center" (square map and radial map)
  • Hello all,

    Just starting out with Construct 3 and having a lot of fun learning the systems.

    I have a question about making a total for all instances of a sprite.

    To give a bit of an overview, in the game I'm currently working on, a player has to move all of a certain type of item into a zone. For example, all blue boxes need to be moved to the blue zone on the game screen. These instances of blue boxes spawn randomly and at the moment I would like to leave the total number of these to be open-ended if possible - although an upper limit can be set if that helps for solving my problem.

    So, what I'd like is to be able to add up a "score" for how many blue boxes are in the blue zone (1 "point" per box). If the player moves a blue box out of the zone, the score would then reduce by 1.

    I've tried playing with a few things but I can't seem to figure out how to do this!

    Any help would be appreciated!

  • The condition would be 'bluebox overlapping bluezone' and then the action is to set a variable to bluebox.pickedcount

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you lionz! This is what I was looking for. However the variable never seems to go below 0 after the first box is placed in the zone, i.e. once I remove all boxes from the zone the variable stays at 1 instead of reducing to 0.

    Do I need to add something to this?

  • Ah yeah that's because the event doesn't run if it can't find any instances that meet the condition, you can add underneath a system Else then set the variable to 0.

  • That worked perfectly.

    Thanks again lionz!

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