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
  • ๐Ÿงพ Step-by-Step Instructions
  • โœ… Summary
  1. Modifying the project

๐ŸŽ How to Add a New Food Item

This page guides you through the process of creating and configuring a new food item in the game using the FoodData system.


๐Ÿงพ Step-by-Step Instructions

1. Create the Food Asset

  • Right-click in the Project window โ†’ Create โ†’ PetCareGame โ†’ Food Data

  • Fill in the following fields:

Field
Description

foodId

Unique ID for this food (must not conflict with others)

foodIcon

Sprite to display in the inventory/shop

foodName

Localized name (multi-language support)

foodDescription

Tooltip/description text

currencyId

Currency required to buy this food (e.g. "GO")

price

Cost of the food in the chosen currency

expWhenEating

EXP gained when pet consumes this item

petStats

Stats restored (e.g., Hunger, Energy)


2. Configure Pet Preferences

You can define how much each pet likes or dislikes this food using the preferences list.

public PetPreference[] preferences;

Each entry links a petId to a PreferenceLevel:

PreferenceLevel
Description

Dislike

Very low chance to eat (unless starving)

Neutral

Standard acceptance chance

Like

High chance to eat and visual feedback

โš ๏ธ If a petId is not listed, the food will use a default neutral chance.


3. Add to GameInstance

To make the new food available in the game:

  • Open the GameInstance Component in Home Scene

  • Add your new FoodData to the foodData array:

public FoodData[] foodData;

This allows the system to load and display the food in shops, menus, and when handling feeding actions.


โœ… Summary

Feature
Supported

Multi-language food names

โœ…

EXP on consumption

โœ…

Per-pet preferences

โœ…

Stat gain on use

โœ…

Shop integration

โœ…

Currency support

โœ…

You can now create dozens of foods with different effects and make each pet respond uniquely to them!

Previous๐Ÿ’ฐ How to Add a New CurrencyNext๐Ÿงข Adding a New Accessory

Last updated 11 days ago