Unity modulation and communication - best practice

Viewed 72

I have several questions:

  1. In a lot of (official and professional) tutorials, the game-manager script manage the objects of the game and also the other objects knows the game-manager. is it not circular dependency and wrong programing architecture?

  2. Another thing that I can't figure out, how to decide where to put each script/behavior? for example, if there is some gift that the player can collect, where (and why) I need to put the code that detect the collision and performs what needs to be done? are there some rules that can help me to decide?

  3. What is the best practice to produce communication between objects and scripts? (A way in which not all objects know everyone)

1 Answers

Personally, for the first question, I would split the game-manager up into an enemy-manager, UI-manager, power-up-manager... This simplifies things by making sure that you clearly understand where everything comes from.

For your second question, I believe for your example, you should put the gift collecting script on the gift. I believe that splitting the scripts of objects are better than focusing the scripts on one object, because it helps you debug any problems that may occur.

For your third question, I still think splitting the game up in to seperate managers to establish communication for the game would be good, but you can also use scriptable objects.

I hope you find this useful!

Related