ボスの機能の作成⑦(登場シーン・BGM変更)
![332dadfe aff6 41ea 966a b2959ad0ff78](https://codegenius.org/uploads/slide/image/7804/332dadfe-aff6-41ea-966a-b2959ad0ff78.jpeg)
ボスの登場シーンの作成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossManager : MonoBehaviour
{
public GameObject boss;
public AudioSource audioSource;
public AudioClip bossBGM;
void Update()
{
transform.Translate(new Vector3(0, 0, -0.005f), Space.World);
Vector3 pos = transform.position;
if (pos.z <= 0)
{
// ボスを出現させる。
boss.SetActive(true);
// BGMのサウンドを切り替える
audioSource.clip = bossBGM;
audioSource.Play();
// 自分をオフ状態にする
this.gameObject.SetActive(false);
}
}
}
![6797beea 8641 4b2c 91bc 606d58a635a6](https://codegenius.org/uploads/slide/image/7805/6797beea-8641-4b2c-91bc-606d58a635a6.jpeg)
![Ad6d59e3 475c 4f2c 95ac e4397405f6c7](https://codegenius.org/uploads/slide/image/7806/ad6d59e3-475c-4f2c-95ac-e4397405f6c7.jpeg)
![9ec10d7e e57c 41a8 9c50 3816b1b6a713](https://codegenius.org/uploads/slide/image/7807/9ec10d7e-e57c-41a8-9c50-3816b1b6a713.jpeg)
【2021版】Danmaku(基礎/全55回)
他のコースを見る![332dadfe aff6 41ea 966a b2959ad0ff78](https://codegenius.org/uploads/slide/image/7804/332dadfe-aff6-41ea-966a-b2959ad0ff78.jpeg)
ボスの登場シーンの作成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossManager : MonoBehaviour
{
public GameObject boss;
public AudioSource audioSource;
public AudioClip bossBGM;
void Update()
{
transform.Translate(new Vector3(0, 0, -0.005f), Space.World);
Vector3 pos = transform.position;
if (pos.z <= 0)
{
// ボスを出現させる。
boss.SetActive(true);
// BGMのサウンドを切り替える
audioSource.clip = bossBGM;
audioSource.Play();
// 自分をオフ状態にする
this.gameObject.SetActive(false);
}
}
}
![6797beea 8641 4b2c 91bc 606d58a635a6](https://codegenius.org/uploads/slide/image/7805/6797beea-8641-4b2c-91bc-606d58a635a6.jpeg)
![Ad6d59e3 475c 4f2c 95ac e4397405f6c7](https://codegenius.org/uploads/slide/image/7806/ad6d59e3-475c-4f2c-95ac-e4397405f6c7.jpeg)
![9ec10d7e e57c 41a8 9c50 3816b1b6a713](https://codegenius.org/uploads/slide/image/7807/9ec10d7e-e57c-41a8-9c50-3816b1b6a713.jpeg)
ボスの機能の作成⑦(登場シーン・BGM変更)