Question by
HamzaKes · Jan 04 at 10:07 AM ·
gameobjectchild objectlevel-design
transform.childCount not working as intended
I am building my first game with unity, a simple break out game.i am intending that when the level has no children it moves to the next level.but it doesn't seem to work.in the code I put this in the update methode.
else if (_currentLevel != null && _currentLevel.transform.childCount == 0)
{
SwitchState(State.LEVELCOMPLETED);
}
break;
which call this code
case State.LEVELCOMPLETED:
Destroy(_currentBall);
Destroy(_currentLevel);
Level++;
PanelLevelCompleted.SetActive(true);
SwitchState(State.LOADLEVEL, 1.0f);
break;
but it doesn't even get into the first condition although in the editor i can see there's no Childrens. PS:Sorry if it's not clear if any more details are needed I will add them.
Comment
Your answer
Follow this Question
Related Questions
Cannot scale an instantiated child 3D object on the Y axis 0 Answers
Save created child object to empty GameObject in GameBuild ( Not Editor ) - Save to XML? 1 Answer
I need help with boss design. I am new to coding so any help would be nice. 0 Answers
How do I check if a child object exists? 5 Answers