Basically, I want to count how many objects (different objects and all their instances) have the variable "selected" set to "yes" and set the value of global variable "unitCount" to the amount counted. However, I don't want to add to the global variable each time "selected" is set to "yes" since it would make certain controls in my project more difficult to make. Any help is appreciated. If there is no way, please let me know. Thanks.
Develop games in your browser. Powerful, performant & highly capable.
1.ALWAYS -> set unitCount to 0
___for each obj ->add 1 to value unitCount
Make sure to set unit count to 0 every frame with the "always", as shown.
I call this type of setup a flush variable, because they never keep their value for more than 1 frame. Event order will matter greatly when using these, because you have to make sure your events which reference unitCount take place after the variable is "filled", otherwise it will just always return zero. Hope this helps!
Or you could use the object.count or countmatching("object") expressions.
Thanks, after looking into it, I think both ways will work for what I need it too. I'll test them out and see which one works best. Thanks a lot!