How can I count my units with different instance variable...

0 favourites
  • 4 posts
From the Asset Store
SCI-FI Units SFX contains 456 sounds With this pack, you can voice almost all the units in your sci-fi strategy game
  • Hi,

    I have one npc type with a "function" instance variable. This variable consist a basic "idle" value. I have six in this npc type.

    I can change their instance variable one by one if I want. So, if I change 4 units inst vari instead of idle to woodcutting I remain 2 npc with idle and 4 with woodcutting inst vari.

    Now, I want to counting that how many woodcutter units I have at this moment and write in a global variable.

    I don't know how should I do this because I need a number to "set global vari", but have no any number except the 6 npc. How can I count how many woodcutters and idle units I have?

    I tried this method:

    Conditions:

    • Every thick
    • Pick nth instance >>> Object: NPC >>> Instance: npc.Function = "woodcutting"

    Actions:

    • Set global variable >>> ??????

    Thank you!

  • System pick by comparison NPC : NPC.function = woodcutting

    system set Global variable : Npc.pickedcount

  • You can use the PickedCount expression.

    NPC.Function = "woodcutting" -> Set global to NPC.PickedCount

    else -> Set global to 0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks! The PickedCount was the missing part. The pick by comparison didn't work.

    I had to use the "pick by evaluate" It's working correctly now

    • pick by evaluate:

    Obj: NPC

    Expression: NPC.Function = "Woodcutting"

    • Set global variable

    Npc.PickedCount

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