Menu
CoddyTech

Shields and Rewards

Part of the Game Architecture in Unity section of Coddy's Unity journey. Lesson 57 of 64.

challenge icon

Challenge

Medium

Add the shield, and make each wave drop a reward.

  1. Shield implements IPickup: Collect calls hero.Protect(duration) and destroys the shield.
  2. In Hero, public void Protect(float seconds) sets safeUntil = Time.time + seconds;.
  3. Give Wave a public GameObject reward. When a wave is cleared, before the rest, the spawner drops it, if set, at its own position.

Press Play and clear wave 1: a heart appears in the middle. Then Check.

Try it yourself

public interface IPickup
{
    void Collect(Hero hero);
}

All lessons in Game Architecture in Unity

Practice on your own: Unity playground