Build a 2D Platformer
Everything you need to create a complete 2D platformer from scratch — movement, camera, advanced mechanics, health, collectibles, and transitions.
Learning Path
Follow these steps in order to build your 2D Platformer.
Included Scripts
2D Player Controller
Complete 2D character controller with smooth movement, variable-height jumping, and coyote time.
[RequireComponent(typeof(Rigidbody2D))]
public class PlayerController2D : MonoBehaviour
{
[SerializeField] private float moveSpeed = 8f;
[SerializeField] private float jumpForce = 16f;
[SerializeField] private float coyoteTime = 0.15f;Smooth Camera Follow 2D
Smooth camera follow with offset, dead zone, and look-ahead for 2D games.
public class CameraFollow2D : MonoBehaviour
{
[SerializeField] private Transform target;
[SerializeField] private Vector3 offset = new Vector3(0f, 1f, -10f);
[SerializeField] private float smoothSpeed = 8f;2D Platformer Mechanics
Wall jump, wall slide, dash, and double jump mechanics for 2D platformers. Drop-in extension for ...
[RequireComponent(typeof(Rigidbody2D))]
public class PlatformerMechanics2D : MonoBehaviour
{
[SerializeField] private bool enableWallJump = true;
[SerializeField] private bool enableDoubleJump = true;
[SerializeField] private bool enableDash = true;Health System
Reusable health component with damage, healing, invincibility frames, and events.
public class HealthSystem : MonoBehaviour
{
[SerializeField] private float maxHealth = 100f;
public float HealthPercent => currentHealth / maxHealth;
public void TakeDamage(float damage)
public void Heal(float amount)Pickup / Collectible
Collectible item with bobbing animation, rotation, magnet pull, and event callbacks for coins, he...
public class Collectible : MonoBehaviour
{
[SerializeField] private int value = 1;
[SerializeField] private string itemId = "coin";
private void OnTriggerEnter(Collider other)
private void OnTriggerEnter2D(Collider2D other)Screen Fader
Simple screen fade-in/fade-out with configurable color and duration. Great for scene transitions.
public class ScreenFader : MonoBehaviour
{
public static ScreenFader Instance { get; private set; }
public Coroutine FadeIn(float duration = -1f)
public Coroutine FadeOut(float duration = -1f)Health Bar UI
World-space or screen-space health bar with smooth fill, color gradient, and damage flash. Attach...
public class HealthBarUI : MonoBehaviour
{
[SerializeField] private float smoothSpeed = 5f;
[SerializeField] private Gradient colorGradient;
public void SetHealth(float current, float max)Damage Popup
Floating damage numbers that animate upward and fade out. Supports critical hits, healing, and cu...
public class DamagePopup : MonoBehaviour
{
public static DamagePopup Create(
Vector3 position, float amount,
bool isCritical = false, bool isHeal = false)Related Systems
2D Platformer Starter Kit
Complete 2D platformer foundation with movement, camera, advanced mechanics, health, collectibles, and transitions.