Hi, I’m designing a check system for a turn based card game and am trying to find the best way to control the state of each game zone :
There are two sides : Ally and Enemy, and I implemented one empty GameObject with a SideController which tells us whether the children GameObjects are Ally or Enemy
Inside this SideControllers, there are different DropZones which can all contain different types of cards.
I’m basically trying to know whether there is a function that allows us to only search within a certain GameObject other than running several nested foreach loops.
You’d better avoid searching game objects hierarchy. This is way too slow for real game. try to mark your objects with tags like Player1, Player2, Player3 and serach by tag. Unity tagging system is little limited because object may have only one tag. But there are extensions on the asset store for that and, of cource, an option to implement your own tagging tailored to your needs.
Thanks for your help!
What about running a series of consecutive checks ?
Like first creating an array of DropZones, then, in a foreach loop, check whether they’re ally or enemy ? I feel like even searching by tag wouldn’t improve my program a lot as I can already single out my DropZones with a GetComponent