Enemy Die

Hey, why not putting
GetComponent<'NavMeshAgent>().enabled = false;
GetComponent<'EnemyAI>().enabled = false;

inside the Die() method, isn’t it more effective than checking if statement in update inside the EnemyAI class?

i tested both warriants and they behave the same

Hi,

Welcome to our community! :slight_smile:

In many cases, there are multiple ways to make something work in Unity, and Rick cannot show all of them. If your code works, it’s a solution by definition. Generally, we try to follow the single responsibility principle in this course whenever possible. Too many dependencies between objects can make debugging challenging, especially in larger projects.

Has your question been answered? :slight_smile:


See also:

1 Like

Yes, now it makes sense :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms