Creating Object Managers
Not every Object in a scene should be something that can be seen, heard, or collided with. Some Objects can also exist with a conceptual meaning, not something tangible. Imagine you need to keep a count of the number of enemies; where do you save that? You also need someplace to save the current score of the Player, and you may be thinking it could be on the Player itself, but what happens if the Player dies and respawns? The data would be lost! In such scenarios, the concept of a Manager can be a useful way of solving this in our first games, so let's explore it.
In this chapter, we are going to look at the following Object Manager concepts:
- Sharing Variables with the Singleton design pattern
- Sharing Variables in Visual Scripting
- Creating Managers
We will start by discussing what the Singleton design pattern is and how it helps us to simplify the communication of Objects. With it we will create Manager Objects, which will allow...