playMaker

Author Topic: Get Child Count  (Read 1481 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Get Child Count
« on: October 05, 2014, 03:21:42 PM »
Hi!

I have an empty child object of another child. Is it a way to count the total number of objects in all the child objecs?

For example:
I create an empty game object called:
-Enemy Group

And then I create empty child objects called:
-Enemy 1
-Enemy 2
-Enemy 3, etc.

If I use get child count on enemy group, it will only count the other child.
Not the total number of objects the childs contains.
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Get Child Count
« Reply #1 on: October 08, 2014, 02:53:18 PM »
That is the expected behavior. You're getting the Child count, not the Children, Grandchildren, Uncles, Cousins, Great Grandchildren, etc..

It uses this built in Unity function.

You'll have to do something else to go deeper, like identifying all of the actual sub-objects first and then counting them.. I don't really know of any quick way (existing action) to do that.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D