Affecting unnamed objects
by Shiraz · in Torque X 2D · 02/24/2007 (12:36 am) · 6 replies
Ok, So I get my player to hit a power-up which should affect all the enemies on the screen. The only problem is, they're all clones created from my SpawnEnemy function and so they have no names. How do I access them so I can change their state?
About the author
#3
02/24/2007 (5:28 pm)
Well, because they're all just mindless drones. I guess I may have to. I can store them in an array, I suppose, and cycle through it when I hit the power-up. I was just hoping there was some way to get a pointer or something to ID them. Since I'm registering them all with the same name I figured there must be a way to access objects with that name.
#4
You could also give them the same (but unique to them) object type and simply loop through all objects of that object type and get them that way.

02/26/2007 (12:48 pm)
Mindless drones deserve names too Shiraz! ;) What I would do is have a generic 'droneX' name where X = the number of the spawned drone. This way you can just do a loop through all objects with drone in the name and then affect them properly.You could also give them the same (but unique to them) object type and simply loop through all objects of that object type and get them that way.

#5
02/26/2007 (4:07 pm)
That's what I meant when I wrote about storing them in an array and cycling through them. Well, I'd store the pointers to them in an array.
#6

02/26/2007 (4:33 pm)
If you give them object types, then you wont have to store them in an array (or pointers) because it's already being done for you.
Torque 3D Owner Will O-Reagan
Modern Intrigues