Virtual Pet Game Template
  • VIRTUAL PET GAME TEMPLATE
  • Getting Started
    • ๐ŸŽฏ Project Setup Guide
    • ๐Ÿงฉ Home Scene Overview
    • ๐Ÿ—บ๏ธ UI Main Menu
    • ๐Ÿ—บ๏ธ LoadingManager
    • ๐Ÿ—บ๏ธ GameInstance
    • ๐Ÿ—บ๏ธ ToolsManager
    • ๐Ÿ—บ๏ธ AudioManager
    • ๐Ÿ—บ๏ธ LanguageManager
    • ๐Ÿ—บ๏ธ MonetizationManager
    • ๐Ÿ—บ๏ธ PlayerSave
  • Modifying the project
    • ๐Ÿพ How to Add a New Pet
    • ๐Ÿ“œHow Add a New Pet Rules
    • ๐Ÿ’ฐ How to Add a New Currency
    • ๐ŸŽ How to Add a New Food Item
    • ๐Ÿงข Adding a New Accessory
    • ๐ŸŽฎ How to Add a New Minigame
  • Modifying Minigames
    • ๐ŸŒค๏ธ Minigame "Jump Sky"
    • ๐Ÿ” Minigame "Food Flicker"
    • ๐Ÿฆ Minigame โ€œFlappyโ€
    • ๐Ÿ’Ž Minigame โ€œGem Hunterโ€
Powered by GitBook
On this page
  • ๐Ÿงพ 1. Creating and Registering a Minigame
  • ๐Ÿ› ๏ธ 2. Setting Up the Minigame Scene
  • โœ… Summary Checklist
  1. Modifying the project

๐ŸŽฎ How to Add a New Minigame

The minigame system in PetCareGame is fully modular, allowing you to add new games with ease using MinigameData assets and custom Unity scenes.


๐Ÿงพ 1. Creating and Registering a Minigame

๐Ÿ”น Create a MinigameData

  1. Right-click in the Project Window

  2. Select Create > PetCareGame > Minigame Data

  3. Fill in the fields in the ScriptableObject:

Field
Description

sceneBuildName

The exact name of the Unity scene (must be in Build Settings)

sceneName

Translated name that appears in the minigame list

sceneIcon

The icon displayed in the minigame UI

๐Ÿ’ก Make sure the scene is added to File > Build Settings and the name matches exactly the sceneBuildName.


๐Ÿ”น Add to GameInstance

Open your GameInstance prefab or object and locate the minigamesData array:

public MinigameData[] minigamesData;

Add the new MinigameData to this list so that it will appear in the gameโ€™s minigame menu.


๐Ÿ› ๏ธ 2. Setting Up the Minigame Scene

๐Ÿ”น Instantiate the Pet Model

In your custom minigame controller script, instantiate the playerโ€™s current pet using:

public PetModel petModel;
public Transform petContainer;

void Start()
{
    petModel = GameInstance.Instance.InstantiatePetModel(petContainer);
}
  • petContainer is the transform where the pet should appear.

  • You can call animations like:

petModel.PlayJump();
petModel.PlayHappy();
petModel.PlaySad();

These methods allow your minigame to feel fully integrated with the core pet system.


๐Ÿ”น Use the EndGamePopup

In the scene, add the prefab EndGamePopupand disable prefab.

Add the EndGamePopup variable to your new minigame's controller and drag the prefab to the referencing field.

public PetModel petModel;
public Transform petContainer;
public EndGamePopup endGamePopup; //Reference

void Start()
{
    petModel = GameInstance.Instance.InstantiatePetModel(petContainer);
}

At the end of the minigame, just call something like this:

public void EndGame()
{
    endGamePopup.gameObject.SetActive(true);
    endGamePopup.Initialize(
        finalScore: 1200,         // ๐Ÿ”ข The player's score at the end of the game
        currencyId: "GO",         // ๐Ÿ’ฐ The ID of the currency used for the reward (must exist in GameInstance)
        currencyAmount: 5,        // ๐ŸŽ How much currency the player will receive as a reward
        won: true,                // ๐Ÿ† Whether the player won (true) or lost (false) the minigame
        gameId: "JumpSky"         // ๐Ÿ•น๏ธ Unique identifier for this minigame (used for best score tracking)
    );
}

This will:

โœ… Update the playerโ€™s currency โœ… Show win/lose UI โœ… Track best score via PlayerSave โœ… Display results and return-to-home button

โ„น๏ธ gameId should be unique per minigame and is used to store high scores.


โœ… Summary Checklist

Step
Required

Create MinigameData asset

โœ…

Add to GameInstance.minigamesData

โœ…

Add the scene to Build Settings

โœ…

Instantiate pet using InstantiatePetModel()

โœ…

Include EndGamePopup prefab

โœ…

This ensures your minigame is fully functional, personalized to the playerโ€™s pet, and integrates seamlessly with the reward and tracking systems.

Previous๐Ÿงข Adding a New AccessoryNext๐ŸŒค๏ธ Minigame "Jump Sky"

Last updated 28 days ago