Plantilla plataformas
ExperimentoPlantilla Unity 6 para plataformas 2D en pixel art: controlador afinado, plataformas, checkpoints y debug.
Más información Abrir en GitHub →
Starting point for 2D pixel-art platformers in Unity 6 (6000.6.5f1), URP 2D Renderer and the Input System. It ships a tuned run-and-jump controller, the classic level pieces (spikes, checkpoints, one-way and moving platforms, level goal) and debug tools, so a new game starts from level design instead of setup.
Everything that can be generated is generated by editor scripts (placeholder art, player prefab, levels), so the project stays easy to rebuild and diff.
Features
- Player controller on a dynamic
Rigidbody2Dwith manual gravity: acceleration/deceleration, air control, exact jump height, coyote time, jump buffer and jump cut. All values in the inspector, in Unity units (1 u = 16 px). - One-way platforms: jump up through them, land on top, drop down with down + jump.
- Moving platforms: kinematic platforms that travel between two points and carry the player, horizontally or vertically.
- Hazards and checkpoints: spikes and kill zones send the player back to the last checkpoint touched (or the level start) with a quick fade.
- Levels: one scene per level; the goal flag fades to black and loads the next level.
- Camera: Cinemachine follow with a confiner to the level bounds; it ignores the height of jumps and re-centres after landing at a new height or falling below it (
PlayerCameraTarget), Pixel Perfect Camera with integer upscale that fills any screen: at least 320x180 px of level are visible, wider or taller screens show more of it (no black bars). Full screen always uses the display's native resolution (FullscreenNativeResolution), and the window can be resized. - Debug: on-screen readout (F1), in-game collider outlines for everything in the scene (F2), respawn (R), editor gizmos.
- Sample levels:
Level01walks through every piece,Level02adds a lift and loops back toLevel01.
Technical setup
| Item | Value |
|---|---|
| Unity | 6000.6.5f1, Universal 2D template (URP 2D Renderer) |
| Reference resolution | 320x180 minimum view, Pixel Perfect Camera, integer upscale, fills the screen |
| Pixels per unit | 16 (1 unit = 16 px) |
| Tiles | 16x16 |
| Character canvas | 48x48, pivot bottom-center (0.5, 0), body 12x20 px collider (Dummy; 12x32 with the placeholder) |
| Input | Input System, keyboard + gamepad at the same time |
| Physics layers | 6 Ground (solid, one-way and moving platforms), 7 Player |
Packages: 2D Aseprite Importer, 2D Pixel Perfect, 2D Tilemap, Cinemachine, Input System. No Asset Store or third-party packages.
Starting a new game
- Create a repository from this template (GitHub Use this template) and clone it.
- Recommended for a game: store art and audio in Git LFS. Run
git lfs installand swap the binary block in.gitattributesfor the commented LFS lines below it. The template itself stays LFS-free, because GitHub template repositories cannot contain LFS content. - In Unity Hub: Add > Add project from disk, pick the folder and open it with 6000.6.5f1.
- Open
Assets/_Project/Scenes/Level01.unityand press Play. - Make it yours:
- Edit > Project Settings > Player: set Company Name, Product Name and the bundle identifier.
- Optionally rename the
Platformerroot namespace: find and replace it inAssets/_Project, including the assembly definitionsPlatformer.RuntimeandPlatformer.Editor. - Replace the placeholder art (see Art pipeline) and build your own levels (see Levels).
If the generated levels or prefab are ever missing or outdated, rebuild them from the Platformer menu: Build Player Prefab, Build Sample Levels (or each level), and Placeholders for the dummy sprite, ground tile and level art.
Controls
| Action | Keyboard | Gamepad |
|---|---|---|
| Move | WASD / arrows | Left stick / D-pad |
| Jump (hold for full height) | Space / J | A / South |
| Drop through a one-way platform | Down + Jump | Down + A |
| Pause (reserved) | Esc | Menu / Start |
Debug keys: F1 readout, F2 collider outlines, R (or gamepad View) respawn at the last checkpoint.
Levels
Each level is a scene with its own player and camera, so any level can be played directly. Levels are built from code with LevelBuilder (Assets/_Project/Editor/LevelBuilder.cs):
var level = LevelBuilder.Begin("Assets/_Project/Scenes/Level03.unity");
level.Shell(width: 48, height: 18, floorTop: 3); // floor, walls, ceiling
level.PlacePlayer(new Vector2(3.5f, 3f));
level.AddSpikes(10, 12, 3); // spike tiles on row 3
level.AddCheckpoint(new Vector2(15.5f, 3f));
level.AddOneWay(18, 21, 5); // top surface at y = 6
level.Clear(26, 0, 33, 2); // a pit in the floor...
level.AddKillZone(new Rect(26f, 0f, 8f, 1.5f)); // ...that kills
level.AddMovingPlatform(new Vector2(27.5f, 2.5f), new Vector2(5f, 0f), speed: 2.5f);
level.AddGoal(new Vector2(45.5f, 3f), "Level01");
level.Finish(); // collision, camera, save, add to build
SampleLevelsBuilder builds the two sample levels and is the reference for every piece. In a scene, the pieces are plain components you can also place by hand: Hazard (any trigger), Checkpoint, LevelGoal (next scene name) and MovingPlatform (travel offset, speed, pause).
Level design notes for the default tuning: the full jump reaches 3.5 tiles up (3 tiles needs a near-full jump) and about 4 tiles across, and the Dummy body is 1.25 tiles tall (20 px), so it fits through 2-tile gaps.
Art pipeline
- Draw on a 48x48 canvas for characters (any editor that exports
.aseprite). - Drop the file into
Assets/Characters/<Name>/. - The 2D Aseprite Importer turns it into sprites and animation clips. Importer settings: PPU 16, pivot bottom-center, Point filter, no compression.
- Hook animations to
PlayerControllerevents (On State Changed,On Jumped,On Landed,On Dropped Through).PlayerAnimatordoes the common case: it plays the Animator state named after the controller state (Idle,Run,Jump,Fall).
The player uses the Dummy character in Assets/Characters/Dummy (Dummy Idle, Dummy Walk, Dummy Jump, Dummy Fall). Platformer > Build Dummy Animations sets up its importers and writes the clips and Dummy.controller; Build Player Prefab uses them (and the placeholder if the folder is missing). Air poses are drawn in place (the controller moves the body): Jump and Fall play once and hold their last frame. Which frames go into each state is the Clips table in DummyAnimationBuilder.
Project layout
Assets/
_Project/
Scenes/ Level01, Level02
Scripts/ runtime code (Platformer.* namespaces)
Player/ PlayerController, PlayerRespawn
Levels/ LevelFlow, LevelGoal, Checkpoint, Hazard, MovingPlatform
Controls/ generated Input System wrapper (PlayerInputActions)
Debugging/ overlay, collider visualizer
Editor/ placeholder art, prefab and level builders
Input/ Player.inputactions
Art/ placeholder sprites and tiles
Prefabs/ Player
Resources/ debug line material
Characters/ imported characters (.aseprite)