🎮 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
MinigameData
Right-click in the Project Window
Select
Create > PetCareGame > Minigame Data
Fill in the fields in the ScriptableObject:
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
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
EndGamePopup
In the scene, add the prefab EndGamePopup
and 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
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.
Last updated