Hi,
I just managed to figure it out that it was my fault in the first place that this situation (looking for child #0 when there is none) could even occur.
In one state I checked the child count and if more then 0 then in the next state used child number 0 for something.
The problem was that I was also modifying child parenting in another FSM simultaneously and quite frequently in the short time-frame (is that 1 frame?) between the 2 states it removed that last child.
So that's solved.
But still when there are no child objects and you try to get child number it should not cause a crash, right?
Jean, your suggestion (count backwards) makes lots of sense, but is that really necessary?
When you get child #0 and parent it to something else or destroy it, doesn't the previous child #1 become #0, etc?
I have been doing these things, like removing all the children from an object this way* without any problem.
*(check child count, if not 0 then remove child #0 and repeat this until child count=0)
Thanks,
szomaza