Are you ready to create a captivating mobile game that will keep players engaged for hours? Look no further! In this comprehensive tutorial series, we'll guide you through the process of developing a hyper casual game from scratch. This third and final part focuses on adding the finishing touches to your game, including scorekeeping, item pickups, and endless obstacles.

Setting Up the Game Over Panel

To start, let's change the background color of our Main Camera to black (or any other color you prefer). Next, add the necessary libraries: SceneManagement and TMPro to the GameManager script. This will enable us to manage scenes and display text using TextMeshProUGUI.

Disabling and Activating the Game Over Panel

In the inspector window, disable the GameOverPanel and set up a public GameObject named GameOverPanel in the GameManager script. When the GameOver function is called, we'll activate this panel. Make sure to save the script and attach it to the GameManager object in your scene.

Restart Button Functionality

Add a RestartGame function to the GameManager script, which will simply load the scene again when called. Then, set up an on-click event for the restart button in the inspector window.

Item Pickups: Collectibles Galore!

Create an empty game object and rename it "Item." On its transform component, set the X position to 3 and the Y position to 6. Add a new diamond sprite with a yellow color and make it a child of the Item game object. Tag this item as "Item" and create a prefab by dragging it from the hierarchy into the Prefabs folder.

Scorekeeping: Increasing the Fun

Open the Player script and add an if statement to detect collisions between the player and objects tagged as "Obstacle" or "Item." When the player collides with an obstacle, call the PlayerDeath function. If they collide with a collectible item, increase the score using the ScoreIncrement function.

TextMeshProUGUI: Displaying the Score

Select the Canvas game object in the hierarchy and create an empty game object named "Score." Make it a child of the Canvas object. Create a UI>TextMeshPro-Text object as a child to the Score object. Adjust the alignment, font asset, and font size values to your liking.

Integrating the Score Text

Open the GameManager script and add a public TextMeshUGUI variable called "currScoreText." Add a private int currScore variable and set it to 0 in the Start function. Then, call the ScoreSetting function. In the Player script, reference the game manager object and call the ScoreIncrement function when the player collides with an item.

By following these steps, you'll be able to create a fully functional hyper casual mobile game that will engage players of all ages. Remember to keep your game development skills sharp by constantly learning new techniques and best practices in mobile game development.