Game Development Community

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?

#1
02/24/2007 (9:37 am)
I have been able to get them through finding "ChildMount0". Check the XML file, reflected from your TGBX editor... Thats where the names of the spawned objects go. But they don't always seem to be named, I'm not sure how it works.
#2
02/24/2007 (4:19 pm)
Why don't you add to the spawn code to name them when they are spawned?

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#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
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.

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#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.

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif