Component disables itself on start, can't find why

I’ve been debugging this for an hour and can’t find the reason. I have a script called Health. When I play the game, the Awake method runs, then the component is disabled, so Start never runs.

I have another script on the same GameObject “UnitController”, and if I remove this script, the disabling of the Health-script stops.

However, I can’t find anything in UnitController that should disable Health. There are just a few lines even referencing it:

Variable: private Health health;
Start: health = GetComponent();

Is there any other action than .enabled = false that can disable a component? It’s really confusing…

Thanks! :slight_smile:

Do you have any errors in the console?

Does UnitController add the health component?

Thanks for the reply!

The health component is there from the start, and it’s not disabled if unitcontroller isn’t there, so I’m trying to remove things from it to see how it can happen, it’s pretty large and lot of other scripts use it, so it’s hard to just delete everything.

But I’ll try… :slight_smile:

You were right, there was a nullreference error in the console for a line in the Awake method of the script that disabled itself, and that was what made it disable itself.

I guess it’s smart, so the game can go on, sloppy of me to miss that in the console.

Thanks for the tip!