Bonus Challenges: Day 2

These optional challenges build on what we did in class!

Make some original graphics for your game

By the end of the week, you should have original art assets in your game, including environment art, characters, items, and more! Start thinking about the theme of your game and working on some tilesets. Refer to the MAKING YOUR GAME LOOK GOOD document for some tips.

Do a bonus challenge from yesterday

Use Vector3.Lerp or Vector3.MoveTowards to dampen camera movement

Add treasures that are worth different amounts of points

︎︎︎ Tips:
  • Give your Treasure script a public variable that represents it’s point value, then reuse that script on different objects.
  • Use different colors or different sprites on treasures with different point values
︎︎︎ Links:

Make the player character flash a color when they collect an item

︎︎︎ Tips:
  • Use your inventory script to manage this, not your Treasure script. You’ll want to control this inside the AddTreasure function
  • Set the tint color of the player characters’ sprite renderer
  • Use color.lerp to gradually return the tint color to white. You can do this in update.

Make the player character play a sound when they collect an item

︎︎︎ Tips:
  • Add an AudioSource component to your player character.
  • Use your inventory script to control the audiosource. You’ll want to do this inside the AddTreasure function
  • Use AudioSource.PlayOneShot or AudioSource.Play to trigger the sound
  • Download a sound effect for free from the internet and import it into unity. You can use Mp3s and Wav files among others.

Add health points and healing items

This works almost identically to the treasure system we made in class!

︎︎︎ Tips:
  • You can add this to the Inventory script or create a separate “Character Health” script.
  • You can add these features to our UI display script, or create a new one specifically for displaying health points. Are health points displayed differently than treasure?
  • Consider imposing a maximum amount of health
  • Consider the difference between using a float to represent health and an int.
  • Consider making it so that healing items are not used if you are at full health
  • Consider playing a different sound when health items are collected

Add hazards that hurt the player (like a lava pit or spikes)

︎︎︎ Tips:
  • Use a trigger to detect when the player is in the hazard
  • Use Time.deltaTime to gradually deplete health, or set up a timer to subtract health at regular intervals
  • What happens when the player runs out of health? consider a simple respawn, similar to how our teleport script works.

Create a health meter

A meter is a more intuitive way to display certain values with a maximum and minimum value, like health points or stamina. 

︎︎︎ Tips:
  • Use an Image component inside your canvas, with image type to “Fill”
  • Consider changing the image color based on how full the meter is, going from green to red using Color.Lerp

Create a switch that must be pressed to open a door

Walk onto the switch to open a door. 

︎︎︎ Tips:
  • Use OnTriggerEnter2D to detect objects entering and exiting the switch

Create a switch that must be held down to keep a door open

If you walk onto the switch, the door opens. If you walk off of the switch, the door swings shut. This requires the player to push a heavy object onto the switch to keep the door open

︎︎︎ Tips:
  • Use OnTriggerEnter2D and OnTriggerExit2D to detect objects entering and exiting the switch
  • use an integer to count the number of objects on the switch, rather than toggling the door open and closed directly in OnTriggerEnter2D and OnTriggerExit2D. This prevents certain glitches where the player could leave an object on the switch and still have the door close unexpectedly.

Create a locked door that requires a key to open

This challenge combines the Inventory with Switches. Consider one or more of these variations:
  • Any key can open any door, but keys are consumed when used.
  • Each key corresponds to a specific door or door type. For example: The green key opens the emerald door, the fire gem lets you pass through fire gates, etc.
  • As a reward for a challenging battle or puzzle, the player gets a “skeleton key” that can open any door.

Also consider whether doors open automatically when you approach with the correct key, or if you have to press a button to use the key.

︎︎︎ Tips:
  • Extend the inventory script to include a separate int for keys. Add a collectible key object to your scene.
  • Create a door that has a trigger attached. The door should check if the player has the correct key before opening.

Create a signpost or stationary NPC that displays text when the player stands next to it

Signposts are a great way to add direction and narrative to your game. Consider triggering text on a keypress.

︎︎︎ Tips:
  • Use OnTriggerEnter2D and OnTriggerExit2D to hide and show a textbox
  • Use a string variable to control what text is displayed in the text box
  • Create a single Text UI element in your canvas that signposts refer to and control.