0 Favourites

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

  • 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

  • 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 can use the PickedCount expression.

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

    else -> Set global to 0

  • 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)