Page 1 of 1

How do I count objects?

PostPosted: Tue Apr 08, 2014 3:54 pm
by henriquesv
Hello!
I need to count objects that are inside an area. For example: 2 objects of type A, 3 objects of type B and so on...

Do I use collision? Overlapping? Something like PickedCount (this one I didn't really understand)?

Any sample that you can show me?

Thank you!

Re: How do I count objects?

PostPosted: Tue Apr 08, 2014 7:23 pm
by Manley23
Yeah, you can use a For Each loop to check if an object is within an area by checking X and Y coordinates or overlapping, and add +1 to variable. If you have similar objects in a Family, that would allow fewer loops.

Re: How do I count objects?

PostPosted: Tue Apr 08, 2014 7:45 pm
by JudyScott
PickedCount is how many of the object is picked. So you check to see if it's overlapping the game area, which picks all those that are, then check the PickedCount to see how many are there.

Re: How do I count objects?

PostPosted: Fri Apr 11, 2014 1:06 pm
by henriquesv
Well done Manley! Listen.. is there anyway to use some kind of Tag to group some objects?
Thanks to you too Judy! Great to know that I can count how many objects one is overlapping!

Re: How do I count objects?

PostPosted: Fri Apr 11, 2014 2:24 pm
by caiorosisca
You can add an instance variable to the objects..called tag for example..and check if that variable is the one you're looking for