ボスの機能の作成⑦(登場シーン・BGM変更)

ボスの登場シーンの作成
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);
}
}
}



【2021版】Danmaku(基礎/全55回)
他のコースを見る
ボスの登場シーンの作成
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);
}
}
}



ボスの機能の作成⑦(登場シーン・BGM変更)