The Goal: Create a game mechanic or mini-game in under a week that involves the Singleton and Object Pooling Design Patterns
in the code's implementation.
1. What GameObjects are you spawning with the Object Pool Design Pattern?
In my minigame, I use the Object Pool Design Pattern to spawn in different obstacles (Short, Medium, and Tall) that the player has to avoid.
2. When is your Object Pool filled with inactive GameObjects? On Start() when the scene loads or does something trigger the pool to be filled? If something triggers it, what triggers the pool to be filled with inactive GameObjects?
The pool is filled with inactive GameObjects on Start() as soon as the GameManager is awake.
3. In your mini-game, what makes the GameObjects be set active and spawn into your scene from the Object Pool? Does the player do something, or is it a repeating coroutine, or something else?
The GameObjects are set active through a repeating coroutine that starts when the game is not paused. The GameObjects are then randomly set active based on what tag is chosen from the random number placed into the array of strings.
4. What makes the GameObjects return to the Object Pool in your mini-game? In the example code, the objects were recycled by adding them to the back of the Object Pool queue when they were spawned. Are you recycling them like that, or adding them back to the queue when something happens in your game? (Either is okay.) If you are adding them back to the queue when something happens, what happens if the pool is empty and the game tries to spawn a GameObject from the pool? Does it spawn an object or not? (Either is okay.)
The GameObjects in the Object Pool are recycled when they reach a certain x position in the scene, being set inactive and being added to the back of the Object Pool queue. Because of this, there should never be a situation where the pool is empty and the game tries to spawn another GameObject, but if that were to happen an already active GameObject would be recycled.
5. What were the benefits of using the Object Pool Pattern to make your mini-game?
While it isn’t apparent in a game of this size, I do believe that this way of spawning and despawning objects is probably more efficient. It also helped to be able to control all my spawnable objects in one class through the inspector, which is more efficient than the other ways I’ve made object spawners in the past.
6. Did you find any drawbacks to using the Object Pool Pattern? If so, what were they?
The only drawback I can think of would be that I already knew a fairly simple way of making obstacles that would spawn and despawn for this kind of game, so learning a new pattern for a game for this small of a scale seemed needlessly complicated, even if it’ll be useful in the future.
7. What were the benefits of using the Singleton Pattern to make your mini-game?
The main benefit for me personally was that I finally figured out why my Singletons weren’t working when I tried to use this pattern in the summer, so that was very helpful! In this game specifically, it was really nice to not have to reference the ObjectPool or the GameManager in every single script that needed them.
8. Did you find any drawbacks to using the Singleton Pattern? If so, what were they?
Not having the GameManager destroyed on load makes saving things much easier between scenes, but I know that for resetting my game it made me have to do a few things manually so that the player’s score and the progress bar would properly reset when the player died.
9. What is the player’s goal in your mini-game and what makes it challenging?
The player’s goal in my mini-game is to survive this 2D side scrolling runner until they reach their home. This is challenging as there are obstacles constantly being spawned in that cause the player to either jump or roll to avoid them.
10. How does the game communicate its goal(s) to the player?
The game communicates the goal to the player through the “how to play” tutorial section that walks the player both through the controls and the goal of the game.
11. How can the player fail at the game and how does the game detect it?
The player can fail at the game by hitting an obstacle before they reach the end of the game. The game detects this by seeing if the player enters the obstacle’s trigger colliders or if the player is not rolling when they enter the tall obstacle’s collider.
12. How does the game give players feedback about how well they are doing?
The game has a progress meter at the top of the screen that shows how close the player is to the toadlet’s home (how close they are to winning.) When the player loses by hitting an obstacle, the game allows them to retry and the progress meter resets.