Thank you for visiting this site.
This article provides a detailed guide to “Stats”, one of Game Creator 2’s modules — the stats and attribute system.
Stats is a module that covers all aspects of RPG-style attribute systems, comprehensively handling Stats (ability values) / Attributes (HP, MP, etc.) / Classes (job templates) / Formulas (expression evaluation) / Tables (experience tables) / Stat Modifiers (equipment bonuses) / Status Effects (status ailments).
Official documentation: Game Creator 2 Documentation
You can find a complete list of all articles in this series here:
What are Stats?
Regardless of whether it’s an RPG, simulation, or fighting game, Stats serve as the foundation for representing characters numerically.
Main objects:
- Stat: A value that grows/changes (e.g., strength, wisdom, luck)
- Attribute: A value with an upper limit (e.g., HP 0–100)
- Class: A combination template of Stats and Attributes (e.g., Warrior, Mage)
- Traits: A component that attaches a Class to a scene GameObject
- Formula: Expressions like
source.stat[atk] - target.stat[def] - Table: Mappings like experience → level
- Stat Modifier: Additive/multiplicative bonuses from equipment or buffs
- Status Effect: Time-based effects like poison/haste
Usage Guidelines
| Pattern | Feature to Use |
|---|---|
| Grows without an upper limit | Stat (strength, wisdom, level…) |
| Upper limit depends on another Stat | Attribute (health is capped by the max_health Stat) |
| Different abilities per character | Class — absorb differences through different initial values for Stats/Attributes |
| +10 only while equipped | Stat Modifier |
| Reduce HP by 1 per second | Status Effect |
Installation
- Purchase the Stats module from the Asset Store
- Install via
Window > Package Manager - Samples from
Game Creator > Install...:- Examples: Sample scenes for each feature
- Classes: Class templates like Warrior/Mage
- UI: HUD/character status screen templates
Stats (Ability Values)
Creation
Right-click in Project → Create > Game Creator > Stats > Stat
Fields
- ID: Unique across the project. Referenced by
source.stat[ID]in Formulas, so short, clear names likestr/strengthare recommended - Base Value: Initial value. Not the final value — it’s the starting point for Formulas
- Formula: If unspecified, final value = Base Value. If specified, the final value is calculated at runtime
- UI: Name / Acronym / Description / Color / Icon
Relationship Between Base and Formula
With Base 100 and Formula = source.base[this] * source.stat[level], you get 100 at Lv1, 200 at Lv2, 300 at Lv3, and so on. Think of Base as the “absolute amount” and Formula as the “growth curve”.
Attributes
Creation
Create > Game Creator > Stats > Attribute
Fields
- ID: Unique.
hp/health, etc. - Min Value: Lower limit (usually 0)
- Max Value: References another Stat. If the max_health Stat increases on level-up, the upper limit automatically increases too
- Start Percent: Initial percentage (most Attributes start at 1.0 for full)
Typical Examples
health: max =max_health(Stat), start = 1.0stamina: max =max_stamina, start = 1.0mana: max =max_mana, start = 1.0
Classes (Templates)
Creation
Create > Game Creator > Stats > Class
Structure
- Attributes: List of included Attributes. Each Attribute’s Start Percent can be overridden within the Class
- Stats: List of included Stats. Base Value and Formula can be overridden within the Class (e.g., Warrior has str=10, Mage has str=4)
Override Philosophy
If you want to create a Mage and Knight with “same mechanics, different numbers”, copying the same Class template and changing only the Base/Formula values is superior for maintainability.
C# Programming Through Unity 3D Game DevelopmentView on Amazon →
Zero to Start! Unity Game Development — Your First TextbookView on Amazon →
Traits (Component to Bind to Characters)
Attaching
Add a Traits component to any GameObject. It doesn’t have to be a Character.
Assigning a Class
Drag & drop a Class asset onto the component. The contents are displayed, and you can override individual Attribute/Stat values for this instance only.
Runtime Display
During play mode, you can check current values in the Inspector, making debugging easy.
Formulas (Calculation Expressions)
Creation
Create > Game Creator > Stats > Formula
Writing Expressions
Write math expressions in the text field. Its job is to return the final value.
source.stat[attack] - target.stat[defense]
Target Notation
source— the caller (attacker, etc.)target— the target (damage receiver, etc.)
Main Symbols
| Type | Syntax | Example |
|---|---|---|
| Stat (Base value) | source.base[id] | source.base[strength] |
| Stat (Final value) | source.stat[id] | source.stat[attack] |
| Attribute | source.attr[id] | source.attr[hp] |
| Local Variable | target.var[id] | target.var[hit-counter] |
Random Functions
random[min, max]: Decimal random number in [min, max]dice[rolls, sides]: Dice roll (dice[2, 6]= roll two 6-sided dice)chance[p]: Returns 1 with probability p, otherwise 0
Arithmetic Functions
min[a, b]/max[a, b]round[v]/floor[v]/ceil[v]
Table Functions (Linked with Tables)
table.level[value]: Returns the level from a cumulative valuetable.value[level]: The cumulative value needed to reach a leveltable.increment[level]: The difference needed for the next leveltable.current[value]: The value earned within the current leveltable.next[value]: The remaining value until the next leveltable.ratio[value]: Progress ratio within the current level (0–1)
Watch Out for Circular References
Circular dependencies where A’s Formula references B and B’s Formula references A are not checked and will cause infinite loops. Be mindful of the dependency graph during design.
Tables (Level Curves)
Creation
Create > Game Creator > Stats > Table
Concept
- Level: Integer level
- Cumulative Value: The total value needed to reach that level (total experience, etc.)
- Value: The value earned within the current level
Types (Progression)
| Type | Overview |
|---|---|
| Manual | Set the required value for each level manually |
| Constant | Same value for all levels |
| Linear | Required value = constant × level (suitable for typical RPGs) |
| Geometric | Required value = level × coefficient (suitable for designs with rapid short-term growth) |
Linking with Formulas
If you set a Table reference field on the Formula asset side, table.* symbols will reference that Table.
Stat Modifiers (Equipment & Buff Bonuses)
Use Case
A mechanism for temporarily adding/multiplying Stats through equipment or buffs. Functions as an overlay layer that increases/decreases Traits Stat values.
Adding
Add Stat Modifier: Specify Target / Stat / Type (Constant or Percentage) / Value.
Removing
Remove Stat Modifier: Removes one Modifier with the same Stat / Type / Value combination.
Calculation Order
Percentage is applied first, then Constant is added. Be aware that the order affects the result.
Status Effects
Creation
Create > Game Creator > Stats > Status Effect
Fields
- ID: Unique across the project
- Type: Positive / Negative / Neutral. Used for classification when batch-removing with
Clear Status Effects Type - Max Stack: How many times the same Status Effect can be stacked
- Save: Whether to persist after loading (remaining time is also saved)
- Has Duration / Duration: Time limit. If OFF, continues until manually removed
- On Start / On End / While Active: Instruction lists for each lifecycle phase
When to Use While Active
- For Poison, place HP reduction logic at regular intervals in
While Active - Place VFX/SFX on activation/removal in On Start / On End
Adding / Removing
- Add Status Effect: Specify target (Traits) and type
- Remove Status Effect: Specify target, removal count, and type
- Clear Status Effects Type: Batch clear by Positive/Negative/Neutral
User Interface (UI Components)
Stat UI
- Target: GameObject with Traits
- Stat: Stat asset to display
- Optional fields: Drag Name / Acronym / Value / Icon / Color to Text/Image components
Attribute UI
- Same basic structure as Stat UI
- Transitions (value change animations): Effects like the HP bar’s “delayed decrease bar”
- Stall Duration: Seconds from value change to delayed animation start
- Transition Duration: Follow-up animation time
Formula UI
Evaluates a Formula between any two characters and displays the result.
Status Effects UI
Two-component structure:
- Status Effect List UI (parent): Aggregates all effects from the target’s Traits. Filterable by Types. Specifying a Prefab auto-generates instances for each effect
- Status Effect UI (child prefab): Displays individual effect icons / remaining time, etc.
Visual Scripting Reference
Instructions (16)
Stats (11)
| Instruction | Function |
|---|---|
| Add Stat Modifier | Add a Modifier to a Stat |
| Remove Stat Modifier | Remove a Modifier with matching values |
| Add Status Effect | Apply a Status Effect |
| Remove Status Effect | Remove a Status Effect |
| Clear Status Effects Type | Batch remove by type |
| Change Attribute | Change an Attribute’s current value |
| Change Stat | Change a Stat’s Base value |
| Set Attribute | Save an Attribute asset to a variable |
| Set Stat | Save a Stat asset to a variable |
| Set Formula | Save a Formula asset to a variable |
| Set Status Effect | Save a Status Effect asset to a variable |
Stats > UI (5)
| Instruction | Function |
|---|---|
| Change AttributeUI Attribute | Change the displayed Attribute in Attribute UI |
| Change AttributeUI Target | Change the target Traits in Attribute UI |
| Change StatUI Stat | Change the displayed Stat in Stat UI |
| Change StatUI Target | Change the target Traits in Stat UI |
| Change Status Effects List UI Target | Change the target Traits in List UI |
Conditions (8)
| Condition | Check |
|---|---|
| Check Formula | Compare a Formula’s result |
| Compare Attribute | Compare an Attribute value |
| Compare Stat | Compare a Stat value |
| Has Stat Modifiers | Whether a specified Stat has Modifiers |
| Has Status Effect | Whether a specified Status Effect is present |
| Is Traits of Class | Whether the Traits’ Class matches |
| Traits Has Attribute | Whether Traits has an Attribute |
| Traits Has Stat | Whether Traits has a Stat |
Events (3)
| Event | Fires When |
|---|---|
| On Attribute Change | When an Attribute value changes |
| On Stat Change | When a Stat value changes (including Modifiers) |
| On Status Effect Change | When a Status Effect is added/removed |
Tips and Notes
- Establish ID naming conventions from the start: Standardize with names like
hp/mp/str/dex/int/wis/luck. A typo in a Formula will be treated as 0, creating hard-to-find bugs - Circular dependencies are your responsibility: Stats doesn’t warn about cycles
- Stat Modifier order: Percentage first, Constant second
- Attribute Max references a Stat: If you set a fixed value for Attribute Max, you can’t increase Max on level-up. The standard practice is to use an intermediary Max Stat
- Status Effect Max Stack: Default is 1. Explicitly increase it for stackable effects like poison
- Save feature: Status Effects save their remaining time as well
- Use Transitions for UI: The “delayed bar” effect on health bars can be implemented using only Attribute UI’s Stall/Transition Duration
- random and chance in Formulas: Avoid in processes requiring reproducibility (replays, etc.)
- Table selection guidance: Linear for long RPGs, Geometric for short ARPGs/MOBAs
Practical Usage — Configuration Guide by Goal
Create an attack - defense damage calculation
Write source.stat[attack] - target.stat[defense] in a Formula asset. The source and target are automatically determined by the instruction’s caller and target.
Make max HP increase on level-up
Link the Stat max-hp with level in its Formula (e.g., source.base[max-hp] * source.stat[level]), and have the Attribute hp’s Max Value reference the Stat max-hp.
Auto-calculate level from an experience table
Select a progression type in a Table asset and write table.level[source.stat[experience]] in the Stat level’s Formula, then link the Table asset.
Temporary stat boost from equipment
Execute Add Stat Modifier on equip and Remove Stat Modifier on unequip. When integrating with the Inventory module, set these in the Item’s On Equip/On Unequip.
Poison status effect (HP drain over time)
Create a Status Effect asset with Type=Negative, and set Change Attribute (HP decrease) in While Active. Place poison effect creation in On Start and effect removal in On End.
Batch removal of buffs/debuffs by type
Properly classify the Type when creating Status Effects, and use Clear Status Effects Type (Type=Negative) for batch clearing.
Create multiple character types with the same Stats/Attributes
Duplicate a Class asset, change only the Stat Base Values and Formulas, and link the corresponding Class to each character’s Traits.
Add randomness to damage calculations
Formula example: (source.stat[attack] - target.stat[defense]) * random[0.8, 1.2] adds ±20% variance.
Create an HUD with HP bars and status effect icons
Place Attribute UI for each Attribute and set Stall Duration + Transition Duration in Transitions to implement a “gradually decreasing bar after damage” effect. Place a Status Effect List UI to auto-arrange icons.
Unity Game Programming Bible 2nd GenerationView on Amazon →
The Game Developer's Map: Lessons from 20 Years of Solo DevelopmentView on Amazon →
Official Links
- Game Creator 2 Official Documentation
- Game Creator 2 — Unity Asset Store
- Stats 2 | Game Creator 2 — Unity Asset Store
Summary
This article covered the Stats module for Game Creator 2.
The Stats module provides a complete set of elements needed for RPG-style numerical systems, from ability value definitions to calculation formulas, experience tables, equipment bonuses, and status effects.
In particular, the declarative damage calculation through Formula assets and the automatic management of equipment bonuses through Stat Modifiers greatly improve maintainability compared to manual implementation with the core alone.
We hope you’ll continue reading our next article as well.
📚 Series: Game Creator 2 Complete Guide (10/16)