勝利条件の設定(enumの使い方)

勝者の決定
using UnityEngine;
using UnityEngine.SceneManagement;
public class Winner : MonoBehaviour
{
// インスペクター上からチームを選択できる(テクニック)
public enum TeamType { Blue, Red };
public TeamType team;
void OnTriggerEnter(Collider other)
{
// もしも自分が青チームで、RedBotが触れてきたら
if (team == TeamType.Blue && other.CompareTag("RedBot"))
{
SceneManager.LoadScene("RedWin");
}
else if (team == TeamType.Red && other.CompareTag("BlueBot"))
{
SceneManager.LoadScene("BlueWin");
}
}
}



【Unity6版】TowerDX(全 回)
他のコースを見る
勝者の決定
using UnityEngine;
using UnityEngine.SceneManagement;
public class Winner : MonoBehaviour
{
// インスペクター上からチームを選択できる(テクニック)
public enum TeamType { Blue, Red };
public TeamType team;
void OnTriggerEnter(Collider other)
{
// もしも自分が青チームで、RedBotが触れてきたら
if (team == TeamType.Blue && other.CompareTag("RedBot"))
{
SceneManager.LoadScene("RedWin");
}
else if (team == TeamType.Red && other.CompareTag("BlueBot"))
{
SceneManager.LoadScene("BlueWin");
}
}
}



勝利条件の設定(enumの使い方)