|
In a predicament. Ol gameObject 1 and gameObject 2 have been getting together on the weekends and giving me spawns. They dont stop! Now i have too many. What can i do. The buggers are everywhere. In a way i guess i want to abort all future children from being instantiated under an object once i reach a nice number like 24. What script functions should i use to achieve this? Thanks for the help.
(comments are locked)
|
|
Not sure what language you want the code in, but you basically need to count the number of items that are contained in the parent's transform. Would do it in UnityScript But you'd probably be better of just having a count variable on the parent and increment it each time you Instantiate a child
Jun 16 '12 at 09:46 AM
whydoidoit
(comments are locked)
|

Instead of using a fairly vague metaphor, could you show us the actual code? It'll be much easier to understand the root cause. What is the intended behaviour?
0 Well thats the reason i gave a vague metaphor. To be a smartass and there is no Code yet. I am wondering if anyone has specific Unity recommended code references to use to achieve this type of effect or perhaps has had experience with this type of setup before.
I would be trying to limit the children via a hard cap under my parent so that i could limit the amount of instantiated player prefabs
I also was more vague then i meant to be. My bad on that. I am simply trying to set a limit to gameObjects Instantiated under a parent.
Thanks for the responses. I will get cracking and post what i used when i get it working.