GAME 1303 — Tier 1 Shared Script Kit
Thirteen C# scripts that give every 2D project in the class a working player, damage, respawn, collectibles, camera, scene flow, audio, HUD, moving platforms and parallax. Written for Unity 6 with the Input System package, Cinemachine 3, and TextMeshPro.
Requirements (Package Manager)
- Input System (Edit → Project Settings → Player → Active Input Handling = Input System Package or Both)
- Cinemachine (3.x on Unity 6; the camera script has a two-line change noted for 2.x)
- TextMeshPro essentials (Window → TextMeshPro → Import TMP Essentials)
Folder layout
Scripts/
- Player/ [[PlayerController2D.cs]], [[PlayerAnimatorBridge.cs]]
- Combat/ Health, [[DamageOnContact.cs]]
- Level/ Checkpoint, [[RespawnManager.cs]]
- Collectibles/ [[ItemType.cs]] (ScriptableObject), [[Collectible.cs]], [[CollectionTracker.cs]]
- Camera/ [[CameraTargetAssigner.cs]] (Cinemachine helper)
- Managers/ [[SceneLoader.cs]], [[GameManager.cs]], [[AudioManager.cs]]
- UI/ [[HUDController.cs]]
- Environment/ [[MovingPlatform.cs]], [[ParallaxBackground.cs]]
Drop the whole Scripts folder into Assets/.
Tags and layers to create first
- Tags:
Player,Enemy - Layers:
Ground
15-minute scene checklist
- Player: Sprite + Rigidbody2D (Freeze Rotation Z, Gravity Scale 3, Continuous) + Collider2D +
PlayerInput(Behavior = Send Messages, use the default actions asset) +PlayerController2D+Health+Animator+PlayerAnimatorBridge. Tag itPlayer. Add an empty childGroundCheckat the feet and assign it. Set Ground Layer =Ground. - Ground: Tilemap or sprites with colliders on layer
Ground. - Camera: GameObject → Cinemachine → 2D Camera. Add
CameraTargetAssignerto the CinemachineCamera. AddCinemachineConfiner2Dand a PolygonCollider2D bounds object if the level has edges. - Managers: one empty object each —
GameManager,RespawnManager,CollectionTracker,AudioManager,SceneLoader(the last two survive scene loads on their own). - Wire events (Inspector, click +):
- Player
Health.OnDied→RespawnManager.OnPlayerDied - Player
Health.OnHealthChanged→HUDController.UpdateHealth RespawnManager.OnLivesChanged→HUDController.UpdateLivesRespawnManager.OnGameOver→GameManager.GameOverCollectionTracker.OnCountChanged→HUDController.UpdateItemCount- Player
PlayerController2D.OnJumped→AudioManager.PlaySFX(string)"jump"
- Player
- Hazards: any sprite + collider +
DamageOnContact. Tick Instant Kill for pits and acid. - Pickups: create an
ItemTypeasset (Create → GAME1303 → Item Type), make a prefab with sprite + trigger collider +Collectible, assign the asset. - Checkpoints: empty + trigger collider +
Checkpoint. - Level exit: trigger with a tiny script or UnityEvent that calls
GameManager.Instance.LevelComplete()thenSceneLoader.Instance.LoadNext().
Animator parameters expected by PlayerAnimatorBridge
Speed (float), IsGrounded (bool), YVelocity (float), Jump / Hurt / Dead (triggers).
Which games skip which scripts
- Top-down (Last Delivery, Weenie Maze): skip
PlayerController2D,MovingPlatform,ParallaxBackground; use the Tier 5TopDownMover/GridMoverwhen written. - Hot Air: skip
PlayerController2D(balloon has its own controller in Tier 3); everything else applies. - Cozy Critters / Store Sim: managers, audio, HUD, and
Collectibleonly. - Static camera games (Weenie Maze, MythoClash, Cozy Critters): no
CameraTargetAssigner; leave the Cinemachine camera's Follow empty.
Notes for the instructor
- Every script has a SETUP block at the top written for students; they shouldn't need this README.
HealthusesUnityEvent<int,int>— in the Inspector these show under Dynamic when you pickHUDController.UpdateHealth, so students must choose the dynamic version, not the static one.PlayerController2DandDamageOnContactuserb.linearVelocity(Unity 6 API). If anyone is on Unity 2022 or earlier, replace everyrb.linearVelocitywithrb.velocity.- No Unity here to compile against, so please do one import pass in a fresh project before handing these out; I've reviewed them by hand but a compiler is the real test.
- Singleton managers use
Instanceand null-check with?.so a scene that lacks one (e.g. no AudioManager yet) doesn't throw.