void Missles() { MissleScript startMissle = GetComponentInChildren <MissleScript>(); if (startMissle) { startMissle.timeToLaunch = true; } }
/// <summary> /// Spawns new missiles to be fired when ready /// </summary> private void MissleSpawning() { if (missleRespawnTime > 0 && !misslesSpawned) // if timer is greater than 0 and missilesSpawned is false { missleRespawnTime -= Time.deltaTime; } if (missleRespawnTime <= 0) // if timer is less than or equal to 0 { missile1 = Instantiate(prefabMissile, missilePos1.position, missilePos1.rotation); // spawns missile 1 missile1.transform.parent = missilePos1; // make missilePos1 a parent of the missile prefab missile2 = Instantiate(prefabMissile, missilePos2.position, missilePos2.rotation); // spawns missile 2 missile2.transform.parent = missilePos2; // make missilePos2 a parent of the missile prefab missleRespawnTime = 10; // time to respawn again misslesSpawned = true; // missiles spawned SoundEffectBoard.RocketMissileSound(); // plays the rocket/missile sound } }