ボス・ステージの作成1(扉が閉まり、中ボスが登場する)




ボス登場
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossTrap : MonoBehaviour
{
public AudioClip closeSound;
public GameObject door_1;
public GameObject boss;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
StartCoroutine(Trap());
}
}
private IEnumerator Trap()
{
// 扉が閉まる音
AudioSource.PlayClipAtPoint(closeSound, Camera.main.transform.position);
// 扉が出現
door_1.SetActive(true);
// Colliderをオフにする
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
yield return new WaitForSeconds(1f);
// ボス出現
boss.SetActive(true);
}
}






【2022版】DarkCastle(全39回)
他のコースを見る



ボス登場
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossTrap : MonoBehaviour
{
public AudioClip closeSound;
public GameObject door_1;
public GameObject boss;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
{
StartCoroutine(Trap());
}
}
private IEnumerator Trap()
{
// 扉が閉まる音
AudioSource.PlayClipAtPoint(closeSound, Camera.main.transform.position);
// 扉が出現
door_1.SetActive(true);
// Colliderをオフにする
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
yield return new WaitForSeconds(1f);
// ボス出現
boss.SetActive(true);
}
}






ボス・ステージの作成1(扉が閉まり、中ボスが登場する)