Okay so looking at Unity it’s hard to determine how to organize the classes and interaction within your project. Many tutorials don’t stress the two principles of development in Unity: Single Responsibility and Modularization.

Single Responsibility and Modularization

From the Unity site: Single Responsibility means that each class is responsible for its own task. Ideally Combining tasks together to accomplish larger more complicated goals.

If you’ve played around with unity and pre-made player/characters to control, called prefabs, you’ve probably seen how those objects are actually several small objects and components placed into one container. Usually you will see that those Player prefabs have a CharacterController and CharacterMotor. That is because of the Single Responsibility ideology.

Unity does a good job of explaining it here:


Dependency Inversion

One way of doing this is Creating Interfaces for all your classes

The Second is to have your classes inherent from one another.

One way to organize your code is to draw out how everything is related and note what every class will need. I know, I know this sounds like doing a UML but abstracting your game idea is super useful for when documenting and organizing your code. If you are planning on making a really cool complex game; creating the core and expanding out is a lot easier, when your code isn’t a huge mess and almost impossible to abstract. Doing this early saves time later on. TRUST ME. It happens all the time especially since Unity makes it so easy to hit the ground running. Or, when you want to rush into development and end up building directly from your proof of concept. Both are sure fire ways of digging your code’s grave at that point.

Anyway. Some food for thought. Also,

Happy Coding!