---
title: "Lesson 4.3 - PowerUp and CountDown"
content_type: tutorial
url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown?language=en"
language: en
difficulty: beginner
duration_minutes: 60
unity_version:
  - "6.0"
  - "6.3"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown.md?language=en&version=6.0"
  - name: "6.3"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown.md?language=en&version=6.3"
  - name: "2022.3"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown.md?language=en&version=2022.3"
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown.md?language=en&version=2021.3"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/leccion-4-3-potenciador-y-cuenta-regresiva.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/4-3gang-paweoeob-mic-kaunteudaun.md?language=ko"
last_updated: "2026-08-04T14:23:20.000Z"
---

# Lesson 4.3 - PowerUp and CountDown

Create a randomly spawning powerup that temporarily boosts player strength and visually indicates its active state.

**Overview:**

The enemy chases the player around the island, but the player needs a better way to defend themselves... especially if we add more enemies. In this lesson, we’re going to create a powerup that gives the player a temporary strength boost, shoving away enemies that come into contact! The powerup will spawn in a random position on the island, and highlight the player with an indicator when it is picked up. The powerup indicator and the powerup itself will be represented by stylish game assets of your choice.

**Project Outcome:**

A powerup will spawn in a random position on the map, eagerly awaiting the player. Once the player collides with this powerup, the powerup will disappear and the player will be highlighted by an indicator. The powerup will last for 5 seconds after pickup, granting the player super strength that blasts away enemies!

Overview: [Video](https://connect-mediagw.unity.com/h1/20241208/videos/dc615777-1f91-44ef-b97e-1933e0d6dea0_CWC_U4.L3.S0_Intro_U6.mp4) ([Transcript (en)](https://connect-mediagw.unity.com/h1/20241209/bd1941a6-b386-4458-a80b-4fb3005fdbb5_CWC_U4.L3.S0_Intro_U6.mp4.vtt))

## 1. Choose and prepare a powerup

In order to add a completely new gameplay mechanic to this project, we will introduce a new powerup object that will give the player temporary superpowers.

[Video](https://connect-mediagw.unity.com/h1/20241208/videos/a13149be-0ca3-4134-8b5f-23c03986ff20_CWC_U4.L3.S1_U6.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn8vfx%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn8vln%22%5D.subtitles/CWC_U4.L3.S1_U6.mp4_20260505_045544.srt))

1. From the _Library_, drag a **Powerup** object into the scene, rename it “Powerup” and edit its **scale** & **position**
2. Add a **Box Collider** to the powerup, click **Edit Collider** to make sure it fits, then check the “**Is Trigger**” checkbox
3. Create a new “Powerup” **tag** and apply it to the **powerup**
4. Drag the **Powerup** into the **Prefabs** **folder** to create a new “Original Prefab”

## 2. Destroy powerup on collision

As a first step to getting the powerup working, we’ll make it disappear when the player hits it and set up a new boolean variable to track that the player got it.

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn8xHD%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn8xN3%22%5D.overviewVideo/Unit%204.3%20-%20Step%202%20-%20Destroy%20powerup%20on%20collision%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170255.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn8xHD%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn8xN3%22%5D.subtitles/Unit%204.3%20-%20Step%202%20-%20Destroy%20powerup%20on%20collision%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170255_20260623_012422.vtt))

1. In **PlayerController.cs**, add a new **_OnTriggerEnter()_** method
2. Add an **if-statement** that destroys **_other.CompareTag("Powerup")_** powerup on collision
3. Create a new **_public bool hasPowerup;_** and set **_hasPowerup = true;_**  when you collide with the Powerup

![](https://connect-mediagw.unity.com/h1/20210924/learn/images/5513c74b-5014-4dec-bb67-55abf1eb6ec4_image.png)

## 3. Test for enemy and powerup

The powerup will only come into play in a very particular circumstance: when the player has a powerup AND they collide with an enemy - so we’ll first test for that very specific condition.

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn8yDb%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn8yJR%22%5D.overviewVideo/Unit%204.3%20-%20Step%203%20-%20Test%20for%20enemy%20and%20powerup%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170411.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn8yDb%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn8yJR%22%5D.subtitles/Unit%204.3%20-%20Step%203%20-%20Test%20for%20enemy%20and%20powerup%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170411_20260623_012444.vtt))

1. Create a new “Enemy” tag and apply it to the **Enemy Prefab**
2. In **PlayerController.cs**, add the **_OnCollisionEnter()_** function
3. Create the **if-statement** with the **double-condition** testing for enemy tag and hasPowerup boolean
4. Create a **Debug.Log** to make sure it’s working

![](https://connect-mediagw.unity.com/h1/20210409/learn/images/f31c2be5-2ede-4fde-a65a-d21b5f36a932_4.3.3.png)

## 4. Apply extra knockback with powerup

With the condition for the powerup set up perfectly, we are now ready to program the actual powerup ability: when the player collides with an enemy with the powerup, the enemy should go flying!

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn8zFp%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn8zLf%22%5D.overviewVideo/Unit%204.3%20-%20Step%204%20-%20Apply%20extra%20knockback%20with%20powerup%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170518.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn8zFp%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn8zLf%22%5D.subtitles/Unit%204.3%20-%20Step%204%20-%20Apply%20extra%20knockback%20with%20powerup%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170518_20260623_012456.vtt))

1.  In **_OnCollisionEnter()_** declare a new **local variable** to get the Enemy’s **Rigidbody** component
2. Declare a new variable to get the **direction** away from the **player**
3. Add an **impulse force** to the **enemy**, using a new **powerupStrength** variable

![](https://connect-mediagw.unity.com/h1/20210924/learn/images/1c99d38d-2205-4edf-bd7a-6aefae3bc4e4_image.png)

## 5. Create Countdown Routine for powerup

It wouldn’t be fair to the enemies if the powerup lasted forever - so we’ll program a countdown timer that starts when the player collects the powerup, removing the powerup ability when the timer is finished.

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn90Ky%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn90Qo%22%5D.overviewVideo/Unit%204.3%20-%20Step%205%20-%20Create%20Countdown%20Routine%20for%20powerup%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170631.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn90Ky%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn90Qo%22%5D.subtitles/Unit%204.3%20-%20Step%205%20-%20Create%20Countdown%20Routine%20for%20powerup%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170631_20260623_012504.vtt))

1. Add a new **_IEnumerator PowerupCountdownRoutine () {}_**
2.  Inside the **_PowerupCountdownRoutine_**, wait 7 seconds, then **disable** the powerup
3. When player **collides** with powerup, start the **coroutine**
4. To fix the error under **IEnumerator**, add the following using directive to the top of your code: **using System.Collections;**

![](https://connect-mediagw.unity.com/h1/20190523/learn/images/6f31653c-2eac-40d4-b15a-c4cbdd8498ba_4_3_5.png)

## 6. Add a powerup indicator

To make this game a lot more playable, it should be clear when the player does or does not have the powerup, so we’ll program a visual indicator to display this to the user.

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn91HM%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn91NC%22%5D.overviewVideo/Unit%204.3%20-%20Step%206%20-%20Add%20a%20powerup%20indicator%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170759.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/92e232aa-01ca-46e3-8396-91b2bd997185/versions%5B_key==%2234536a756a3b%22%5D.sections%5B_key==%22rbCl1Be6HAVyj2JQSn91HM%22%5D.body%5B_key==%22rbCl1Be6HAVyj2JQSn91NC%22%5D.subtitles/Unit%204.3%20-%20Step%206%20-%20Add%20a%20powerup%20indicator%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_170759_20260623_012515.vtt))

1. From the _Library_, drag a **Powerup** **object** into the scene, rename it “Powerup Indicator”, and edit its **scale**
2. **Uncheck** the “**Active**” checkbox in the inspector
3. In **PlayerController.cs**, declare a new **_public GameObject powerupIndicator_** variable, then assign the **Powerup Indicator** variable in the inspector
4. When the player collides with the powerup, set the indicator object to **Active**, then set to **Inactive** when the powerup expires
5. In **_Update()_**, set the Indicator position to the player’s position + an **offset value**

![](https://connect-mediagw.unity.com/h1/20190523/learn/images/9a24c7d2-7d8a-46e5-b261-f24d6a792e74_4_3_6.png)

## 7. Lesson Recap

## New Functionality:

- When the player collects a powerup, a visual indicator appears
- When the player collides with an enemy while they have the powerup, the enemy goes flying
- After a certain amount of time, the powerup ability and indicator disappear

## New Concepts and Skills**:**

- Debug concatenation
- Local component variables
- IEnumerators and WaitForSeconds()
- Coroutines
- SetActive(true/false)

## Next Lesson**:**

We’ll start generating waves of enemies for our player to fend off!

## Check your scripts:

PlayerController.cs

```csharp
using System.Collections;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    public float playerSpeed = 150f;
    public bool hasPowerup;
    public GameObject powerupIndicator;

    private InputSystem_Actions controls;
    private Rigidbody playerRb;
    private GameObject focalPoint;
    private float powerupStrength = 15.0f;

    void Awake()
    {
        controls = new InputSystem_Actions();
        playerRb = GetComponent<Rigidbody>();
        focalPoint = GameObject.Find("Focal Point");
    }

    void OnEnable()
    {
        controls.Player.Enable();
    }

    void Update()
    {
        Vector2 moveInput = controls.Player.Move.ReadValue<Vector2>();
        float forwardInput = moveInput.y;
        playerRb.AddForce(focalPoint.transform.forward * forwardInput * playerSpeed * Time.deltaTime);
        powerupIndicator.transform.position = transform.position + new Vector3(0, -0.5f, 0);
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Powerup"))
        {
            hasPowerup = true;
            Destroy(other.gameObject);
            StartCoroutine(PowerupCountdownRoutine());
            powerupIndicator.gameObject.SetActive(true);
        }

    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Enemy") && hasPowerup)
        {
            Rigidbody enemyRigidbody = collision.gameObject.GetComponent<Rigidbody>();
            Vector3 awayFromPlayer = (collision.gameObject.transform.position - transform.position);

            Debug.Log("Collided with " + collision.gameObject.name + " with powerup set to " + hasPowerup);
            enemyRigidbody.AddForce(awayFromPlayer * powerupStrength, ForceMode.Impulse);
        }
    }

    IEnumerator PowerupCountdownRoutine()
    {
        yield return new WaitForSeconds(7); hasPowerup = false;
        powerupIndicator.gameObject.SetActive(false);
    }

}
```
