PREFABS: COINS, GEMS & ENEMIES

Create reusable game object templates from Kenney sprites

Lesson 10 Prefabs — Reusable Templates Unity 2D — Year 9 Kenney Assets
1
Coin Prefab Assets
Sprites for collectible coins & gems

Available Coin & Gem Sprites

FileLocationUsage
coinGold.pngBase pack/Items/Standard coin (+10 pts suggested)
coinSilver.pngBase pack/Items/Medium coin (+5 pts)
coinBronze.pngBase pack/Items/Common coin (+1 pt)
gemBlue.pngBase pack/Items/Rare gem (+25 pts)
gemRed.pngBase pack/Items/Ultra rare gem (+50 pts)
gemGreen.pngBase pack/Items/Bonus gem (+25 pts)
gemYellow.pngBase pack/Items/Bonus gem (+25 pts)

Create a Coin Prefab — Step by Step

  1. Drag coinGold.png into the Scene
  2. Rename to "Coin" in Hierarchy
  3. Add Component → Circle Collider 2D → tick Is Trigger
  4. Create Tag "Coin" (Inspector top → Tag → Add Tag)
  5. Assign "Coin" tag to the object
  6. Create Assets/Prefabs/ folder
  7. Drag the "Coin" from Hierarchy into Assets/Prefabs/ — blue name = prefab!
  8. Delete the scene instance (it lives in Prefabs now)
💡 Design choice! Should bronze=1, silver=5, gold=10, gems=25? This is YOUR game design decision! Different point values create different player experiences.
2
Enemy Prefab Assets
Sprites for enemy characters

Basic Enemies (Base Pack)

FileLocationUsage
slimeWalk1.pngBase pack/Enemies/Ground enemy (Easy)
flyFly1.pngBase pack/Enemies/Flying enemy (Medium)
snailWalk1.pngBase pack/Enemies/Slow enemy (Easy)
fishSwim1.pngBase pack/Enemies/Water enemy (Special)

Advanced Enemies (Extra Animations Pack)

FileLocationUsage
bat.pngExtra.../Enemy sprites/Dark areas (Medium)
bee.pngExtra.../Enemy sprites/Outdoor (Medium)
spider.pngExtra.../Enemy sprites/Cave/wall (Hard)
ghost.pngExtra.../Enemy sprites/Castle (Hard)
snake.pngExtra.../Enemy sprites/Desert (Medium)
frog.pngExtra.../Enemy sprites/Forest (Hard)
mouse.pngExtra.../Enemy sprites/Fast, small (Medium)
worm.pngExtra.../Enemy sprites/Underground (Easy)
ladyBug.pngExtra.../Enemy sprites/Outdoor (Easy)

Create an Enemy Prefab — Step by Step

  1. Drag slimeWalk1.png into Scene
  2. Rename to "Enemy_Slime"
  3. Add Box Collider 2D → tick Is Trigger
  4. Add Rigidbody 2D (Dynamic, so it falls)
  5. Create Tag "Enemy", assign it
  6. Drag into Assets/Prefabs/
  7. Delete scene instance
⚠️ Rigidbody 2D makes the enemy affected by gravity. If you want enemies to float (like ghosts or bats), set Gravity Scale to 0 in the Rigidbody component.
3
Power-Up Prefab Assets
Extension challenge — bonus collectibles

Available Power-Up Sprites

FileLocationEffect
mushroomRed.pngBase pack/Items/Extra life
mushroomBrown.pngBase pack/Items/Grow bigger
star.pngBase pack/Items/Invincibility
keyBlue.pngBase pack/Items/Unlock blue door
keyRed.pngBase pack/Items/Unlock red door

Power-Up Prefab Setup

  1. Drag the power-up sprite into Scene
  2. Add Circle Collider 2D
  3. Tick Is Trigger ON
  4. Create and assign Tag: "PowerUp"
  5. Drag into Assets/Prefabs/
Extension challenge: Power-ups are great for students who finish early. Each one needs its own C# script to define what happens on pickup!
4
Spawner Setup Quick Reference
Configure invisible spawner objects

Spawner Configuration

Spawner ObjectPositionPrefabSpawn Interval
CoinSpawnerY = 6 (above screen)Coin (Gold)2 seconds
EnemySpawnerY = 6 (above screen)Enemy_Slime3 seconds
💡 Create empty GameObjects for spawners: Right-click Hierarchy → Create Empty. They are invisible — they just run the Spawner script. Position them above the camera view so objects fall into the scene.
Y=6 +-----------+ <-- Spawner sits here (invisible) | CoinSpawner | +-----------+ | v coins fall down ======================== <-- Top of camera view | | | Player sees | | coins falling | | into the scene | | | ======================== <-- Bottom of camera view
5
Prefab Component Checklist
Quick reference for all prefab types

Component Setup Summary

Prefab Type Sprite Collider Is Trigger Rigidbody Tag
Coin coinGold.png Circle 2D ON Optional "Coin"
Gem gemBlue.png Circle 2D ON Optional "Coin"
Enemy slimeWalk1.png Box 2D ON Dynamic "Enemy"
Power-Up star.png Circle 2D ON Optional "PowerUp"
⚠️ Is Trigger must be ON for all collectibles and enemies. Without it, the player will physically bump into them instead of passing through and triggering the pickup/damage script.
Common mistake: Forgetting to assign the Tag. Your OnTriggerEnter2D script checks CompareTag("Coin") — if the tag is missing, nothing happens when the player touches the coin!