๐ŸŽ 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!

Last updated