I am trying to create a Boss fight scenario in a topdown shooter in which when the player crosses a boundary, a number of enemies are instantiated, and then when the number of enemies reaches zero, then the boss fight is over.
I am trying to use Unity’s sendmessage things but they aren’t working and I dont know why. I tried to write this in chronological order but it might be a little messed up.
Thanks in advance!
//CrossBoundary Script
function OnTriggerExit(other : Collider){
//player crosses line
if (other.gameObject.collider.tag == "Player"){
SendMessage("BossStart");
SendMessage("Enemies");
//Sets BossFight to true on enemy script
function BossStart(){
BossFight = true;
}
//death function on enemies
function Death(){
dead = true;
Destroy (gameObject);
Instantiate(EnemyDiesParticles, transform.position, transform.rotation);
dead = false;
if (dead == true && BossFight == true){
SendMessage("EnemyCounter");
}
//"gamemaster"
function Enemies () {
for (var i = 0; i < BossNumber; i++)
Instantiate(Enemy, BossSpawn.position, Quaternion.identity);
enemyCount = BossNumber;
}