Guide B — Shared Reference

The parts that appear in more than one game, written once. Your own guide will point you here.


B1. The standard player prefab (2D platformer)

Eleven of the seventeen games use this. Build it once, save it as a prefab, and your guide will tell you what to add on top.

Build it

  1. GameObject → Create Empty, name it Player.
  2. Set its Tag to Player (dropdown at the top of the Inspector). This is the most important single step in the whole build — 29 scripts look for it.
  3. Add a Sprite Renderer and drop in your character sprite. No art yet? Use one of Unity's built-in sprites (Add Component → Sprite Renderer, then click the circle next to Sprite and pick Square), and colour it something obvious.
  4. Add these components:
Component Settings
Rigidbody2D Gravity Scale 3 · Collision Detection Continuous · Constraints → Freeze Rotation Z ✓
Capsule Collider 2D size it to the sprite; leave a tiny gap at the bottom
Player Input Actions → your input actions asset · Default Map Player · Behavior: Send Messages
PlayerController2D see below
Health Max Health 3
Animator leave the Controller empty for now
PlayerAnimatorBridge finds the others automatically
  1. Right-click Player → Create Empty, name it GroundCheck. Move it to the very bottom of the sprite — just at the feet, not below them.
  2. Select Player again. In PlayerController2D:
    • Ground Check → drag the GroundCheck child in
    • Ground Layer → tick Ground (and nothing else)
  3. Drag Player from the Hierarchy into Assets/MyGame/Prefabs/.

PlayerController2D — the fields worth knowing

Field Default What it does
Move Speed 8 how fast you run
Acceleration 60 how quickly you reach that speed — higher is tighter
Deceleration 80 how quickly you stop — lower is more slippery
Jump Force 14 how high
Coyote Time 0.1 seconds after leaving a ledge where you can still jump
Jump Buffer Time 0.1 seconds before landing where a jump press is remembered
Jump Cut Multiplier 0.5 release jump early to jump lower. 1 = fixed-height jumps
Fall Gravity Multiplier 1.8 heavier while falling — stops jumps feeling floaty

Coyote time and jump buffering are why the controls feel good. They let you jump a fraction of a second after walking off a ledge, and let a jump pressed slightly early still work when you land. Players never notice them working; they very much notice them missing. Leave them alone until you've played the game.


B2. The scene manager objects

These are plain empty GameObjects with one script each. Make them once per scene.

GameObject Component Notes
GameManager GameManager pause, win, lose
RespawnManager RespawnManager leave Player empty — it finds the tag
AudioManager AudioManager survives scene changes on its own
SceneLoader SceneLoader survives scene changes on its own
CollectionTracker CollectionTracker only if you have collectibles
ChoiceFlagManager ChoiceFlagManager only if your guide says so

AudioManager and SceneLoader survive scene loads. Put them in your first scene only. If you put them in every scene you'll get duplicates — harmless, they delete themselves, but confusing in the Hierarchy.

Sounds

On AudioManager, expand Named Sounds and add an entry per sound. Each has a Name (what scripts ask for) and a Clip. Common names across the kit:

jump · land · hit · collect · death · door_open · door_locked · level_complete

No audio yet? Skip it. Every sound call is optional — a missing sound is silence, not an error.


B3. The camera (Cinemachine)

  1. GameObject → Cinemachine → 2D Camera. This adds a CinemachineBrain to your Main Camera and creates a CinemachineCamera object.
  2. Select the new CinemachineCamera and Add Component → CameraTargetAssigner. Leave Target empty — it finds the Player tag on Start.
  3. On the Position Composer, good starting values for a platformer:
Setting Value Why
Damping X 0.5 camera lags slightly — feels smooth
Damping Y 1.0 more vertical lag, so jumps don't jolt the view
Dead Zone Width 0.1 small moves don't push the camera
Dead Zone Height 0.2
Screen Y 0.6 player sits slightly low, so you see more ahead

Stopping the camera at the level edge

  1. Add CinemachineConfiner2D to the CinemachineCamera.
  2. GameObject → Create Empty, name it CameraBounds. Add a Polygon Collider 2D, tick Is Trigger, and edit its points to outline your level.
  3. Drag CameraBounds into the confiner's Bounding Shape 2D.

A static camera

Some games (a single-screen maze, an arena) don't want any of this. Just don't add CameraTargetAssigner and leave Follow empty.


B4. The standard enemy prefab

  1. Empty GameObject, name it, Tag → Enemy.
  2. Sprite Renderer + your enemy sprite.
  3. Components:
Component Settings
Rigidbody2D Freeze Rotation Z ✓
Capsule Collider 2D fit the sprite
Health Max Health 2 · Destroy On Death ✓ · Invulnerability Time 0
Knockback (only if you have Tier 2 combat)
EnemyPatrol see below
  1. Two empty children: WallCheck (in front, at chest height) and LedgeCheck (in front, just below the feet). Drag both into EnemyPatrol. Set Ground Layer → Ground.
  2. A child called Hurtbox: Box Collider 2D with Is Trigger ✓, plus a Hurtbox component with Team = Enemy. Set the child's Layer to Hurtbox.
  3. A child called BodyHitbox: trigger collider + Hitbox component, Target Team = Player, Damage 1, Repeat Delay 1. Layer → Hitbox. Leave this one enabled — it's touch damage, not a swing.

Hurtbox = where I can be hit. Hitbox = what hurts you. Every fighting thing in the kit has one of each. The Hitbox/Hurtbox layers only collide with each other (the setup tool did that), which stops attack boxes snagging on walls.


B5. The twelve wirings

These are UnityEvent connections you make by hand in the Inspector. Your guide lists the ones you need; this is the full set for reference.

On this object Event Call this
Player Health On Died RespawnManager.OnPlayerDied
Player Health On Health Changed HUDController.UpdateHealth (Dynamic)
RespawnManager On Lives Changed HUDController.UpdateLives (Dynamic)
RespawnManager On Game Over GameManager.GameOver
CollectionTracker On Count Changed HUDController.UpdateItemCount (Dynamic)
Player PlayerController2D On Jumped AudioManager.PlaySFX → type jump
Attack hitbox Hitbox On Hit ComboCounter.RegisterHit (Stardust)
Player Health On Damaged ComboCounter.ResetCombo (Stardust)
EnemyChase On Attack MeleeAttack.Attack
LevelExit On Completed LevelTimer.StopAndRecord (Zap Attack)
RespawnManager On Respawned PushBlock.ResetPosition (puzzle games)
Player Health On Died CharacterSwapper.OnCurrentCharacterDied (Roach Invasion — instead of the first row)

B6. Animator parameters

Only add the ones your character actually uses. Every script checks whether a parameter exists and skips it silently if not — so a missing parameter means "no animation," never an error.

Parameter Type Set by
Speed Float movement
IsGrounded Bool movement
YVelocity Float movement
Jump Trigger jumping
Hurt / Dead Trigger Health
Attack / Shoot Trigger attacking
Dash / DoubleJump / Launch Trigger Tier 3 modules
IsGliding / IsWallSliding / IsClimbing / IsRiding Bool Tier 3 modules
MoveX / MoveY Float top-down movement

Minimum viable animator

Two states, one parameter:

[Idle] ── Speed > 0.1 ──▶ [Walk] ── Speed < 0.1 ──▶ [Idle]

On both transitions, untick "Has Exit Time" and set Transition Duration to 0. This is the single most important animator setting in the kit. Left on, Unity waits for the current animation to finish before switching, and your character feels a quarter-second late to everything.

Add Jump and Fall when you're ready:

From To Condition
Any State Jump Jump trigger (untick Can Transition To Self)
Jump Fall YVelocity < 0
Any State Fall IsGrounded false and YVelocity < −0.1
Fall Idle IsGrounded true

B7. Things that don't need an Animator

Worth knowing before you spend an afternoon: most animated objects in these games are animated by code. Spinning saws rotate themselves. Crushers move themselves. Spikes pop up by themselves. Collectibles bob by themselves. Doors slide by themselves.

You only need an Animator for characters — the player, enemies, a pet. Everything else in your hazard and level list is already moving.