How do I Add to Global Variable for each Object

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.
  • Ok so basically Im creating a RTS game. So when I place down a Building, I want it to add 1 to the global variable every second

    Then placing the same building will add another 1 every second making it 2 every 1 second but when i placed the second object down it still counts as if theres only 1

    I tried

    For Each Building-

    Building On Layout Game-

    Building Not pinned- Every 1 second add 1 to Global

    But as said it only adds 1 every 1 second no matter how many buildings I place down.

    Any idea how to fix this? If possible post a capX please!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can simply add Building.count

    It's the number of Building instances in your game.

  • Lol thanks for that! Thats actually really useful but thats not what Im looking for atm

    It wont stack when laying down multiple buildings or objects

    I place 1 Oil Building down, its starts adding to the global but when adding another building it still stay at the same paste, I want it to for each building add 1 to the global

  • Ok, then do this -

    Add Timer behavior to building.

    When Building is created, start a recurring timer "AddOil".

    On "AddOil" timer event, add 1 to Oil.

    Timer is a much better option here than using "Every X second" or "Wait".

    In "On timer" event you can do different checks - say, if building is upgraded, you can add 2 oil. Or you can stop the timer when player pauses the game etc.

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