Game Designing Patterns in Unity

Vikash Kumar Prajapati
2 min readJun 24, 2021

Whenever I use to code, I was able to bring my imagination to code but still felt that this is not the best way to do this, so what is?
Then I came across this term called Design Pattern. When I go through the Linked post of Khushboo Gupta and got to know about this, So design patterns stands for a programming concept which solves conceptual problems. It can be related to creating new objects, making the code more independent or modular, or even split your project into different layers of responsibility.

Following Design Pattern

These are patterns or a structure that you can follow to solve commonly occurring problems. These patterns make your code robust, easy to read and modify. These are extensively used in every development company for better understandability of code within various departments. This is not specific to any industry, they are used in every product development company whether it is web or Software or Game.

Here are the some common or basic design patterns that you might have followed ever but you may even know what exactly this patterns called, I will explain these in the context of game development -

Singleton Design Pattern: Allows only one instance of a class to be created. Should be used in manager/controller scripts where entire logic is written.

Composite Design Pattern: Provides a unified access point to all classes. It is like having different buttons on the screen controlled by one function which return calls by the respective method.

Observer Design Pattern: Allows classes to interact with each other without knowing anything about them. Say Player enters a war zone, so we can notify all the enemies/observers in the scene that the player has entered via this pattern. It basically a one to many dependency between objects so that one object changes state, all of its dependents are notified and updated automatically.

Strategy Design Pattern: Provides flexibility by decoupling class behaviors. For example, take mouse/keyboard inputs from one class and send the data to logic for moving player in another class. I other words we can say that it makes the algorithms interchangeable within that family.

Model-View-Controller Design Pattern : we can call it as a life saver ,it is highly used in any big scale project. Model contains only dumb data. It like, View only puts the data to screen in a dumb manner because Controller is the real brain that applies logic to data, get the result and sends it to View.

Like these design patterns there are many more that you might have followed ever, many development company while taking interview, they use to ask about what design pattern you mainly use to follow because these are the most common thing that every coders use to follow.

--

--