Example of how and where would the LooselyCoupledEnemy.Attack() be called

Howdy! The video was pretty much helpful and really clear of how to reduce the tight between scripts, but a question that I had with the enemy script is how would this be implemented in runtime. Since the enemy is the one that would trigger the “Attack()” method I am a bit confusing of who will call this method now. It would be really nice to see some example of how this would happen in practice.
Thanks for the class in advance!

As Sam has mentioned; it was really just an example of how high cohesion/low coupling would look over the inverse. It’s not really a real-world implementation. In that sample’s case, however, you’d likely have some enemy AI that will choose an IAttackable game object and pass to the Attack method in order for the attack to happen.

2 Likes

Ah I see, thanks for helping me understand it! :))

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

Privacy & Terms