So my code for my game’s enemy’s animator component is
private Animator enemyAnim;
before the Start method, and in the Start method it says
enemyAnim = GetComponent<Animator>();
which has been working perfectly when I had just one enemy in the hierarchy, but when I have been using its prefab Unity says:
“UnassignedReferenceException: The variable enemyAnim of EnemyBehavior has not been assigned.
You probably need to assign the enemyAnim variable of the EnemyBehavior script in the inspector.”
How can I get it to work with the prefab as well?