---
title: "レッスン 4.3 - パワーアップとカウントダウン"
content_type: tutorial
url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp?language=ja"
language: ja
difficulty: beginner
duration_minutes: 60
unity_version:
  - "2022.3"
  - "2022.2"
  - "2022.1"
  - "2021.3"
  - "2021.2"
  - "2021.1"
  - "2020.3"
  - "2020.2"
  - "2020.1"
  - "2019.4"
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
supported_unity_versions:
  - name: "2022.3"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2022.3"
  - name: "2022.2"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2022.2"
  - name: "2022.1"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2022.1"
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2021.3"
  - name: "2021.2"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2021.2"
  - name: "2021.1"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2021.1"
  - name: "2020.3"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2020.3"
  - name: "2020.2"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2020.2"
  - name: "2020.1"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2020.1"
  - name: "2019.4"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2019.4"
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/lesson-4-3-powerup-and-countdown-jp.md?language=ja&version=2018.4"
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"
---

# レッスン 4.3 - パワーアップとカウントダウン

島にランダム出現するパワーアップでプレイヤーの力を一時的に強化し、インジケーターで効果を視覚的に示します。

**概要：**

敵はプレイヤーを島中追いかけ回すようになりました。このため、プレイヤーには自分の身を守るためのより良い方法が必要です。特に敵を増やしたとき、身を守る良い方法がなければ生き残ることはできません。このレッスンでは、プレイヤーを一時的に強くするパワーアップの仕組みを作成して、接触してくる敵を押しのけられるようにします。パワーアップアイテムは島のランダムな位置に出現し、拾うとプレイヤーにインジケーターが付いてパワーアップしたことがわかるように表示されます。パワーアップのインジケーターとパワーアップアイテムは、好みのスタイリッシュなゲームアセットで表現されます。

**プロジェクトの成果物：**

パワーアップアイテムは、プレイヤーが拾える状態でマップ上のランダムな位置に出現します。プレイヤーがこのパワーアップアイテムに接触すると、パワーアップアイテムは消滅し、プレイヤーにインジケーターが付きます。パワーアップはアイテムを拾った後 5 秒間持続し、その間プレイヤーは敵を吹き飛ばせる状態になります。

## 1. 導入

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/0692fbcf-888a-45d1-adc0-2e83c2c09651_CWC_Intro_4_3.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20200727/a706fe4e-ad1b-41ac-9bf8-242c6cba5f82_CWC_Intro_4_3.vtt.vtt))

## 2. パワーアップアイテムを選んで準備する

> _今回はまったく新しいゲームプレイのメカニクスを追加するために、プレイヤーを一時的に強化する新しいパワーアップアイテムを導入します。_

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/98dbe564-86af-45ae-a7d6-c2e56f03cf94_CWC_U4.L3.S1.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/7c8a4b13-921c-4904-9783-bdde7b39b60a_146_Lesson_43_Choose_and_prepare_a_powerup.en.vtt))

1. Library から、**Powerup** オブジェクトをシーンにドラッグし、「Powerup」と名前を変更し、**大きさと位置**を編集します。
2. Powerup に **Box Collider** を追加し、**Edit Collider** をクリックしてちょうどいい大きさにして、「**Is Trigger**」チェックボックスにチェックを入れます。
3. 新しく「Powerup」**タグ**を作成し、それを **Powerup** に適用します。
4. **Powerup** を **Prefabs フォルダー**にドラッグして、新しい「オリジナルのプレハブ」を作成します。

## 3. 触れた時にパワーアップアイテムを消去する

> _パワーアップを動作させるための最初のステップとして、プレイヤーが触れたときにパワーアップが消えるようにして、プレイヤーがパワーアップアイテムを拾ったことを記録する新しいブーリアン変数を設定します。_

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/5a834106-7761-437a-9064-af343aba16ed_CWC_U4.L3.S2.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/bd1e41b9-661b-4c08-b8ec-dd26950bb480_147_Lesson_43_Destroy_powerup_on_collision.en.vtt))

1. **PlayerController.cs** に、新しく **OnTriggerEnter()** メソッドを追加します。
2. 衝突時に **other.CompareTag("Powerup")**を条件文に持つ **if 文**を追加し、パワーアップアイテムに触れた時に消去するようにする。
3. 新しく **public bool hasPowerup;** を作成し、パワーアップアイテムに接触したら **hasPowerup = true;** と設定するようにする。

![](https://connect-mediagw.unity.com/h1/20190523/learn/images/40910599-843d-46df-bf6c-07ad02da9030_4_3_2.png)

## 4. 敵キャラとパワーアップをテストする

> _パワーアップは、プレイヤーがパワーアップを持っていて、かつ敵と衝突した場合という、非常に特殊な状況下でのみ効果を発揮します。そのため、まずこの非常に特殊な状況をテストしましょう。_

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/8e515f56-f10f-4ac6-805c-12c667ad5554_CWC_U4.L3.S3.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/6a352a3b-fa9d-447d-9fff-4680b22ce1ee_148_Lesson_43_Test_for_enemy_and_powerup.en.vtt))

1. 新しく「Enemy」タグを作成し、**Enemy プレハブ**に適用します。
2. **PlayerController.cs** で、**OnCollisionEnter()** 関数を追加します。
3. 敵タグのブーリアン値 hasPowerup と Enemy タグの **2 つの条件**をテストする **if 文**を作成します。
4. **Debug.Log** を作成して動作していることを確認します。

![](https://connect-mediagw.unity.com/h1/20190529/learn/images/1aa287b4-3692-4f7c-8f08-62db43d630ac_4.3_3.PNG)

## 5. パワーアップ時に追加される弾き飛ばす力を適用する

> _これでパワーアップの条件が完璧に整ったので、パワーアップ機能の中身をプログラムする準備が整いました。プレイヤーがパワーアップしているときに敵とぶつかったら敵が飛んでいくようにしましょう。_

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/2ffc4d0b-ee8b-45dd-af38-0b7efb060b55_CWC_U4.L3.S4.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/67f435c5-8cd0-47ec-bd2b-9e83635d0cb9_149_Lesson_43_Apply_extra_knockback_with_powerup.en.vtt))

1. **OnCollisionEnter()** で、敵の **Rigidbody** コンポーネントを取得するための新しい**ローカル変数**を宣言します。
2. **プレイヤー**から離れる**方向**を保持するための新しい変数を宣言します。
3. 新しい変数 **powerupStrength** を使用して、**敵**に**衝撃力**を与えます。

![](https://connect-mediagw.unity.com/h1/20190819/learn/images/d2de7867-aa59-419b-a5ef-5898dad49da6_Screen_Shot_2019_08_19_at_11.03.30_AM.png)

## 6. パワーアップのカウントダウンを行うルーチンを作る

> _パワーアップが永遠に続くと敵との力のバランスが崩れるので、プレイヤーがパワーアップを拾った時に発動するカウントダウンタイマーをプログラムし、タイマーが終了するとパワーアップ機能を停止するようにします。_

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/192c6e99-396a-4a85-b653-fb394bf12341_CWC_U4.L3.S5.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/d78695dd-043e-42cb-ad9d-d8668413a8e9_150_Lesson_43_Create_Countdown_Routine_for_powerup.en.vtt))

1. 新しく **IEnumerator PowerupCountdownRoutine () {}** を追加します。
2. **PowerupCountdownRoutine** の中で 7 秒待ってから、Powerup を**無効**にします。
3. プレイヤーがパワーアップに**触れたら**、**コルーチン**を起動します。

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

## 7. パワーアップのインジケーターを追加する

> _このゲームをよりプレイしやすくするためには、プレイヤーがパワーアップをしたときとしなかったときが明確にわかるようにしておくべきです。そこで、パワーアップしているかどうかをユーザーに示す視覚的なインジケータをプログラムします。_

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/0071e14b-3575-4b52-bdf1-7d4d802fa770_CWC_U4.L3.S6.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/88e98936-15f1-49f3-ba85-5826718d4982_151_Lesson_43_Add_a_powerup_indicator.en.vtt))

1. _Library_ から、**Powerup オブジェクト**をシーンにドラッグし、「Powerup Indicator」と名前を変更し、**大きさ**を編集します。
2. インスペクターの「**Active**」チェックボックスの**チェックを外します**。
3. **PlayerController.cs** で、新しく **public GameObject powerupIndicator** 変数を宣言し、インスペクターで **Powerup Indicator** 変数を割り当てます。
4. プレイヤーがパワーアップに触れたとき、インジケーターのオブジェクトを**アクティブ**に設定し、パワーアップの有効期限が切れたら**非アクティブ**に設定します。
5. **_Update()_** で、インジケーターの位置をプレイヤーの位置に**オフセット値**を加えた位置に設定します。

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

## 8. レッスンのまとめ

[Video](https://connect-mediagw.unity.com/h1/20200727/videos/d6595da8-d8f3-457f-af1e-6b1c0647955c_CWC_U4.L3.SRecap.mp4) ([Transcript (ja_jp)](https://connect-mediagw.unity.com/h1/20220506/d02fd0b6-f441-4b52-aa34-2adcd923a539_152_Lesson_43_Lesson_Recap.en.vtt))

新しい機能：

- プレイヤーがパワーアップを拾うと、視覚的なインジケーターが表示されます。
- パワーアップ中に敵と衝突すると敵が飛んでいく
- 一定時間経過するとパワーアップ能力とインジケーターが消える

新しい概念とスキル：

- デバッグメッセージの連結
- ローカルのコンポーネント変数
- IEnumerators と WaitForSeconds()
- コルーチン
- SetActive(true/false)

次のレッスン：

- プレイヤーが次々に現れる敵の集団を撃退するようなゲームにしましょう。
