> For the complete documentation index, see [llms.txt](https://university-of-games.gitbook.io/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university-of-games.gitbook.io/welcome/products/complete-game-tutorials/2d-platformer-toolkit.md).

# 2D Platformer Toolkit

2D Platformer Toolkit for Unity 6 — modular character controller with coyote time, combat, enemies, platforms and HUD. Docs by University of Games.

![2D Platformer Toolkit](https://raw.githubusercontent.com/universityofgames/2d-platformer-toolkit/main/Marketing/cover_1950x1300.png)

![Gameplay](https://raw.githubusercontent.com/universityofgames/2d-platformer-toolkit/main/Marketing/gameplay.gif)

**2D Platformer Toolkit** is a free, modular toolkit with everything a classic (GBA-style) 2D platformer needs — drop the components into your own project and build levels instead of boilerplate.

{% hint style="info" %}
**Who is this for?** Indie developers and small teams building 2D side-scrollers who want a tight character motor, combat, collectibles, enemies and level elements without writing the same boilerplate every project.
{% endhint %}

{% hint style="success" %}
**Requirements:** Unity **6000.0+** · built-in **Input Manager** · **TextMeshPro** (HUD) · no external package dependencies beyond Unity UI / TMP
{% endhint %}

***

## In plain language — what do you get?

A namespaced runtime assembly (`PlatformerToolkit.Runtime`) of drop-in MonoBehaviours:

1. **Tight character controller** — physics-based motor with acceleration curves, variable jump height, gravity shaping, coyote time, jump buffering, wall slide/jump, dash, crouch and ladder climbing.
2. **Health & damage** — hit points with invulnerability frames, contact damage with knockback, kill zones, projectiles and Yoshi-style flicker.
3. **Collectibles & enemies** — coins, health pickups, keys; ground and flying patrols with Mario-style stomping.
4. **Level elements** — checkpoints, moving / falling / one-way platforms, springs, locked doors, level exits.
5. **Camera & HUD** — smooth follow with look-ahead, coin counter and heart-based health display.
6. **Clean architecture** — XML-documented public API, tooltips on every field, UnityEvents *and* C# events on everything.

All components live under **Add Component → 2D Platformer Toolkit**.

***

## Quick start

{% stepper %}
{% step %}

### Install

Clone the repository or copy the `Assets/2DPlatformerToolkit` folder into your Unity **6000.0+** project.
{% endstep %}

{% step %}

### Open the demo

Open `Assets/2DPlatformerToolkit/Demo/Scenes/Playground.unity` and press Play. Arrows / A-D to run, Space to jump. The scene exercises coins, enemies, checkpoints, a moving platform, a spring, a kill-zone pit and a HUD.
{% endstep %}

{% step %}

### Drop components into your level

Create a player sprite with **Rigidbody2D** + collider, add **Character Motor 2D** (set *Ground Mask*) and **Player Controller**. Wire hazards, pickups and platforms from the recipes below.
{% endstep %}

{% step %}

### Hook feedback

Every gameplay component exposes **UnityEvents** (`Landed`, `Jumped`, `Damaged`, `Died`, `Collected`, `Stomped`, …) — attach sounds, particles and screen shake without writing code.
{% endstep %}
{% endstepper %}

***

## Features

<table data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><h3>🏃</h3></td><td><strong>Character motor</strong></td><td>Acceleration curves, variable jump, apex assist, wall slide/jump, dash, crouch, ladders, corner correction.</td></tr><tr><td><h3>❤️</h3></td><td><strong>Health &#x26; combat</strong></td><td>HP with i-frames, contact damage + knockback, kill zones, projectiles, hit-stop, damage flicker.</td></tr><tr><td><h3>🪙</h3></td><td><strong>Collectibles</strong></td><td>Coins, health pickups and keys with an extensible <code>Collectible</code> base class.</td></tr><tr><td><h3>👾</h3></td><td><strong>Enemies</strong></td><td>Ground patrol (walls &#x26; ledges), flying waypoint patrol, Mario-style stomp.</td></tr><tr><td><h3>🚩</h3></td><td><strong>Level toolkit</strong></td><td>Checkpoints, moving / falling / one-way platforms, springs, locked doors, level exits.</td></tr><tr><td><h3>🖥️</h3></td><td><strong>Camera &#x26; HUD</strong></td><td>Smooth follow with look-ahead and bounds; TMP coin counter and heart health UI.</td></tr></tbody></table>

***

## Documentation map

| Page                         | Contents                                                                    |
| ---------------------------- | --------------------------------------------------------------------------- |
| Getting Started & Recipes    | **How to start** tutorial, player setup, component recipes                  |
| Your Own Assets              | Replace demo sprites, Animator, tilemaps, audio and HUD                     |
| Characters API               | `CharacterMotor2D`, `PlayerController`, animator, respawner, squash/stretch |
| Combat API                   | `Health`, damage, projectiles, kill zones, flicker                          |
| Collectibles & Enemies API   | Pickups, patrol enemies, stomp                                              |
| Level, Camera, UI & Core API | Platforms, doors, camera, HUD, session, pause, hit-stop                     |
| Extending the Toolkit        | Project roadmap, custom gameplay, growing beyond the demo                   |

***

## Architecture

```mermaid
flowchart LR
    Input["PlayerController / AI"] --> Motor["CharacterMotor2D"]
    Motor --> RB["Rigidbody2D"]
    Health["Health / IDamageable"] --> Damager["ContactDamager / Projectile"]
    Session["GameSession"] --> Coin["Coin / KeyPickup"]
    Session --> Door["LockedDoor"]
    Checkpoint["Checkpoint.Active"] --> Respawn["PlayerRespawner"]
```

### Design principles

1. **Motor vs. controller** — `CharacterMotor2D` never reads input. Controllers (or AI) drive it via `MoveInput`, `Jump()`, `Bounce()`, `TryDash()`, etc.
2. **Layer masks, not tags** — interaction filters use `LayerMask` fields.
3. **Composition** — enemies = `PatrolEnemy` + `Health` + `ContactDamager` + `Stompable`.
4. **Dual events** — designer UnityEvents plus C# events for scripting.
5. **Session singleton** — `GameSession` (`DontDestroyOnLoad`) tracks coins and keys across scenes.

### Assembly

| Property         | Value                                 |
| ---------------- | ------------------------------------- |
| Assembly         | `PlatformerToolkit.Runtime`           |
| Root namespace   | `PlatformerToolkit`                   |
| References       | `UnityEngine.UI`, `Unity.TextMeshPro` |
| `autoReferenced` | `true`                                |

### Namespaces

| Namespace                        | Contents                                                      |
| -------------------------------- | ------------------------------------------------------------- |
| `PlatformerToolkit.Characters`   | Motor, player controller, animator, respawner, squash/stretch |
| `PlatformerToolkit.Combat`       | Health, damage, projectiles                                   |
| `PlatformerToolkit.Collectibles` | Pickup base and variants                                      |
| `PlatformerToolkit.Enemies`      | Patrol enemies, stompable                                     |
| `PlatformerToolkit.Level`        | Checkpoints, platforms, doors, exits                          |
| `PlatformerToolkit.Cameras`      | Camera follow                                                 |
| `PlatformerToolkit.UI`           | HUD widgets                                                   |
| `PlatformerToolkit.Core`         | Session, pause, hit-stop, utilities                           |

***

## Package layout

```
Assets/2DPlatformerToolkit/
├── Runtime/            Gameplay code (PlatformerToolkit.Runtime)
│   ├── Cameras/
│   ├── Characters/
│   ├── Collectibles/
│   ├── Combat/
│   ├── Core/
│   ├── Enemies/
│   ├── Level/
│   ├── UI/
│   └── PlatformerToolkit.Runtime.asmdef
├── Demo/               Playground scene, sprites, animations, prefabs
├── Documentation/      GettingStarted.md
└── CHANGELOG.md
```

***

## Default controls

| Action               | Input               | Default binding       |
| -------------------- | ------------------- | --------------------- |
| Run                  | `Horizontal`        | Arrows / A-D          |
| Jump / wall jump     | `Jump`              | Space                 |
| Dash                 | `Fire1`             | Left Ctrl / mouse 0   |
| Climb ladders        | `Vertical`          | Up/down near a ladder |
| Crouch               | Down while grounded | Down / S              |
| Drop through one-way | Down + Jump         | Down + Space          |
| Pause (`GamePauser`) | `Cancel`            | Esc                   |

Uses Unity's **legacy Input Manager** (`Input.GetAxisRaw` / `Input.GetButtonDown`), not the new Input System.

***

## Layers & tags

**No tags are required.** Filtering is done with LayerMasks.

| Object                 | Suggested layer       | Targeted by                                             |
| ---------------------- | --------------------- | ------------------------------------------------------- |
| Player                 | custom `Player`       | `ContactDamager.targetLayers`, `KillZone`, projectiles  |
| Ground / platforms     | `Default` or `Ground` | `CharacterMotor2D.groundMask`, `PatrolEnemy.groundMask` |
| Collectibles / hazards | any                   | respective `*Layers` fields                             |

Demo defaults: player on layer **6** (`Player`); ground mask = Default (`m_Bits: 1`).

***

## Version history

{% updates format="short" %}
{% update date="2026-08-03" tags="major" %}

## 1.0.0 — Initial release

Modular rebuild of the character controller into namespaced components: full motor (wall jump, dash, crouch, ladders), combat, collectibles, enemies, level elements, camera, HUD, `GameSession`, hit-stop and Playground demo.
{% endupdate %}
{% endupdates %}

***

## Support

Questions about the package? Reach us via the [Unity Asset Store publisher page](https://assetstore.unity.com/publishers/25633) or the channels listed under Community.
