Add [SelectionBase] to the Health.cs to save annoyances throughout the course!


I am almost done with the course and as soon as we got character models on the player and enemies, they are full of children (for each body part of the prefabs we use) meaning, that clicking a character in the scene view OFTEN selects a child of the game object like an arm or a torso, and to get to the parent game object you have to sort through the Hierarchy panel. To solve this constant problem, I have come from the future to offer a solution!

In this lecture we created the Health.cs script. If you add: [SelectionBase] to the top of the script, for the rest of the class, whenever you select a character by clicking them in the scene view you will always select the parent game object first, which has all the components on it, and you can of course drill down if you need to look at a child game object too. I hope this helps someone else earlier than I figured it out! Take care!

TLDR: Example of the top of the script when you are done:

public class Health : MonoBehaviour

Thanks, that’s a very handy tip!

< NECRO > Very cool.

Privacy & Terms