Stopping when not in range - checking my understanding

I just want to see if I’m on the right track here.

 GetComponent<Mover>().Stop();

So this references the Mover.cs script and calls the method from it?

Would it be possible to code navMeshAgent.isStopped = true; directly into Fighter? The reason why we are not doing that is so as not to have circular dependencies right?

While you can code this directly into Fighter, it’s not Fighter’s job to start and stop the character, it’s the Mover’s job. By having Fighter call the NavMeshAgent directly rather than going through Mover, we introduce an opportunity for bugs and unintended consequences. It’s very hard to debug a piece of code, if certain things are accessible from just everywhere. By using the Mover.Stop() method, we ensure a central point where the NavMeshAgent.isStopped=true; is set.

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

Privacy & Terms