What could cause a script's reference to an Animator to become null?

I have a prefab that has an Animator and a script controlling the animator. The animator is connected to the script in the editor. The prefab is a character, and I instantiate 2 of them to battle each other. I run through a couple of abilities just fine; their animations are both working. But eventually I get a null reference exception due to animator being null in my script. I don’t ever assign the animator variable via script, I link it in via the inspector and then only reference it from there on out. After the null reference occurs I check the instantiated copy of the prefab and sure enough the animator slot on my script is “none”. Any ideas?

Turns out I was editing an animation when I linked the animator to the script. Apparently linking references is something the animation can automate.

That’s how prefabs are. You have to set the external references/Getcomponent calls via it’s Awake/OnEnable/Start.