//if the enemies intersect out of bounds box then they get destroyed
    private void OnTriggerEnter(Collider other)
    {
        SpawnEnemeies se = enemySpawner.GetComponent <SpawnEnemeies>();

        if (other.CompareTag("Enemy"))
        {
            Destroy(other.transform.root.gameObject);
            se.enemyCount--;
        }
    }
Exemple #2
0
    //checks for collisions with enemies
    private void OnTriggerEnter(Collider other)
    {
        SpawnEnemeies se = enemySpawner.GetComponent <SpawnEnemeies>();

        if (other.CompareTag("Enemy") && attacking)
        {
            attack.score += 100;
            killParticle();
            exploder = ((Transform)Instantiate(particleSys, other.transform.position, other.transform.rotation)).gameObject;
            Destroy(other.transform.root.gameObject);
            //attacking = false;
            se.enemyCount--;
            splatSound.Play(0);
        }
        Invoke("killParticle", 0.2f);
    }
 // Start is called before the first frame update
 void Start()
 {
     se = enemySpawner.GetComponent <SpawnEnemeies>();
 }