Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
In between a war and a hard place life goes on and code is written. But since I'm not in the happiest mood to write something constructive I'll complain. And what shall I complain about, oh great and noble sir or madam? What a silly question... Unity of course.
Let us imagine a game object. An entity if you please. And let us call it, um, I don't know, "Amir". Let us delve deeper into the mysteries of creation and attach three other entities to "Amir" (parenting if you will). We shall dub these, "Rob", "Bob" and, eh, "Slob". Why not?
To each of these strange and wonderful objects we'll endeavour to attach a single component called "Health". Now, four entities, four components. Let me paint you a picture. A simple one, of hard lines and boxes. Of the UML persuasion.
Pop quiz, hotshot.
Amir.GetComponentsInChildren<Health>()
How many components have we got?
My wife's (who is both amazing and wonderful) first reaction was:
"Are you really going to teach me programming at ten at night?"
I proceeded to get a notepad and she sighed, resigned. Her second reaction, after a quick sketch.
"Three"
And if that wasn't your first reaction you should probably think long and hard about life in general... Of course if that was your first reaction you probably haven't been working with Unity for very long either.
"Ah ha!" I exclaimed loudly, "You would think so!". Then hung my head, "But the answer is four".
I'll end this post with a quote from the Unity's documentation page.
Returns all components of Type [type] in the GameObject or any of its children.
Why? F*** if I knew...
"In truth I haven't played much since the baby came in June but give me half a minute an' I'll get this fiddle back in tune"
Read more about:
Featured BlogsYou May Also Like