> For the complete documentation index, see [llms.txt](/llms.txt)

# Skill Tree

Unlocks abilities node by node, each with its own prerequisites and cost, tracked per character.




**About this demo**

The demo signs in automatically with an anonymous account. The account is shared across every demo in the showroom, so items and currency you get in one demo carry over to the others. Loading takes a moment. If the frame is too small, open the demo in a new tab.

## Overview

Recruit a character, open its skill tree, and spend coins to unlock nodes. The tree has four nodes, `first`, `left`, `right` and `last`: `left` and `right` each require `first`, and `last` requires both `left` and `right`. Progress is kept separately for each character, and an unlocked node can be put back for half of what it cost.

## How to try it

1. Press **Recruit** under **Recruit a character**. A row for the character appears under **Open a character's tree**.
1. Press **Deposit** under **Get coins** to put 100 free coins into **Your coins**. The four nodes cost 10, 20, 20 and 50, exactly 100 in total.
1. Press **Open tree** on the character's row. The **Skill tree** opens, showing each node's name, its cost, and what pressing it would do.
1. Press **Release** on `first` to pay 10 coins and unlock it. Pressing **Release** on a node whose prerequisites are still locked unlocks those prerequisites in the same press, as the node's line says (`releases 2, 30 total` on `left`).
1. Press **Restrain** on an unlocked node to lock it again, along with any unlocked nodes that depend on it; 50% of the cost comes back as coins.
1. Press **Close**, recruit another character and open its tree to see that each character keeps its own progress.

## GS2 services used

- [GS2-SkillTree](/microservices/skill_tree/): GS2-SkillTree node models define the four nodes, their prerequisites, the coins each charges on release, and the return rate of 0.5 when one is put back. Progress is recorded per recruited character, keyed by its item set (`propertyId`).
- [GS2-Money2](/microservices/money2/): A GS2-Money2 wallet holds the coins. Releasing a node withdraws its cost through `Gs2Money2:WithdrawByUserId`.
- [GS2-Inventory](/microservices/inventory/): GS2-Inventory holds the recruited characters; each character's item set GRN is the key that says whose skill tree is being read.
- [GS2-Exchange](/microservices/exchange/): GS2-Exchange rate models define **Recruit**, which grants a character, and **Deposit**, which pays in free coins.

## Use it in GS2 Studio

In GS2 Studio's Simple mode, open **Add features** and press **Add** on **Skill Tree** to bring this feature into your own project. To point at the package directly, choose **Add from GitHub** and enter the package below.

```text
https://github.com/gs2io/gs2-studio-package/tree/main/micro-economy-skill-tree/packages/micro-economy-skill-tree
```

- Owner: `gs2io`
- Repository: `gs2-studio-package`
- Subdirectory: `micro-economy-skill-tree/packages/micro-economy-skill-tree`

## Source code

- Demo project: <https://github.com/gs2io/gs2-studio-package/tree/main/micro-economy-skill-tree/live-demo>
- Feature package: <https://github.com/gs2io/gs2-studio-package/tree/main/micro-economy-skill-tree>



