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
  • ๐Ÿ“‹ Overview
  • ๐Ÿ” How to Add New Stages
  • ๐Ÿง  Assigning Stages to the Spawner
  • ๐Ÿงฉ Editing or Creating New Food Prefabs
  • ๐ŸŽฎ Player Movement & Controls
  • ๐Ÿ Ending the Game
  • ๐Ÿ” Summary Checklist
  1. Modifying Minigames

๐Ÿ” Minigame "Food Flicker"

The Food Flicker minigame is a reflex-based game where the player catches falling food items while avoiding bad items. The gameplay progresses through multiple stages, each with its own difficulty.


๐Ÿ“‹ Overview

  • ๐ŸŽ Good Foods: Add score and gold when caught.

  • ๐Ÿ’€ Bad Foods: Penalize the player when caught or missed.

  • ๐Ÿช™ Coins: Grant additional gold.

  • ๐Ÿ’ฅ Game Over: Triggered by too many missed foods or by completing all stages.


๐Ÿ” How to Add New Stages

Each stage is defined using the StageDefinitionFoodFlick ScriptableObject.

โž• Creating a New Stage

  1. Right-click in the Project window โ†’ Create โ†’ PetCareGame โ†’ Minigame-FoodFlick โ†’ Stage Definition

  2. Configure the following properties:

Field
Description

spawnRate

Delay (in seconds) between item drops.

maxMissed

Max number of missed foods allowed before failure.

scoreThreshold

Score required to pass this stage.

goodFoodPrefabs

Array of prefabs considered "good" (to catch).

badFoodPrefabs

Array of prefabs considered "bad" (to avoid).

coinPrefab

The coin prefab to spawn occasionally.

coinChance

Probability [0โ€“1] of spawning a coin.

badFoodChance

Probability [0โ€“1] of spawning a bad food.

All prefabs must have a Collider2D and the script FoodItemGame attached.


๐Ÿง  Assigning Stages to the Spawner

  1. Locate the FoodDropSpawner object in the Minigame_FoodFlick scene.

  2. Drag and drop your new StageDefinitionFoodFlick asset(s) into the stages list in the Inspector.

The game will transition between stages as the player scores enough points (scoreThreshold).


๐Ÿงฉ Editing or Creating New Food Prefabs

All food items must have:

  • A Collider2D with isTrigger enabled.

  • The FoodItemGame script attached.

  • Tag: Untagged (can vary depending on how it's used).

  • Layer: optional, but ensure proper collision.

Set the following on FoodItemGame:

  • foodType: Good or Bad.

  • scoreValue: Score the item grants when caught.

  • catchSound / missSound: Optional SFX.


๐ŸŽฎ Player Movement & Controls

Player logic is handled by FoodPlayerController. You can:

  • Change movement speed via moveSpeed.

  • Adjust horizontal limits with maxXPosition.

The pet model is instantiated at runtime using GameInstance.Instance.InstantiatePetModel() inside the controller.


๐Ÿ Ending the Game

The game ends in two scenarios:

  • The player catches enough food to meet the last stageโ€™s scoreThreshold (win).

  • The player misses too many items (maxMissed reached) (lose).

Upon ending:

  • Final score and gold are shown.

  • Coins are added to the player using PlayerSave.AddCoin().

  • Best score is saved via PlayerSave.SetBestScore("FoodFlick", currentScore);


๐Ÿ” Summary Checklist

โœ… New stage created using StageDefinitionFoodFlick โœ… Assigned to the FoodDropSpawner.stages list โœ… Food prefabs properly configured with FoodItemGame โœ… Game auto-transitions between stages based on score โœ… Game over occurs on fail or final stage completion

Previous๐ŸŒค๏ธ Minigame "Jump Sky"Next๐Ÿฆ Minigame โ€œFlappyโ€

Last updated 28 days ago