Game Development Community

How to iterate over all player objects ?

by Orion Elenzil · in Torque Game Engine · 03/04/2007 (2:04 pm) · 4 replies

This seems like a silly question,
but does anyone have a good way to iterate over all player objects in the simulation ?

the messaging system iterates over the ClientGroup,
which is pretty good, except i want to include NPCs, which aren't in there.

tia,
orion

#1
03/04/2007 (2:26 pm)
No built in mechanic, if you need an occasional iteration then create a new SimSet and every spawn of the class(es) you want, add it to the set in the ::onAdd() method. Then, iterate over that set.

Alternatively, if it's a constant poll of the objects per tick, just do whatever would be the response per object to the iteration it directly in ::processTick().
#2
03/04/2007 (2:36 pm)
Thanks for getting back Stephen.

It's just an occasional iteration.
I'm actually doing the former, it's just a little ugle to remember that i've got player objects in 3 different SimGroups.

thanks!
#3
03/04/2007 (2:39 pm)
Well in this particular case, no reason at all to use a SimGroup--I'd just use a SimSet.
#4
03/04/2007 (2:46 pm)
Ohh, i getcha. yeah.. thanks!