In my game, the enemies don’t shoot one laser at a time, they shoot a stream of lasers. Help?
using UnityEngine;
using System.Collections;
public class EnemyMove : MonoBehaviour
{
public float timeBetweenAttacks;
public GameObject shot;
public Transform shotSpawn;
public Transform shotSpawn1;
public AudioClip laser;
Transform player;
//PlayerHealth playerHealth;
//EnemyHealth EnemyHealth;
NavMeshAgent nav;
void Awake ()
{
player = GameObject.FindGameObjectWithTag ("Player").transform;
//playerHealth = player.GetComponent <PlayerHealth> ();
//EnemyHealth = GetComponent <EnemyHealth> ();
nav = GetComponent <NavMeshAgent> ();
}
void Update ()
{
//if(EnemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
//{
nav.SetDestination (player.position);
//}
//else
//{
//nav.enabled = false;
//}
if(Time.deltaTime <= timeBetweenAttacks)
{
timeBetweenAttacks = timeBetweenAttacks + Time.deltaTime;
AudioSource audio = GetComponent<AudioSource>();
audio.clip = laser;
Instantiate (shot, shotSpawn.position, shotSpawn.rotation);
Instantiate (shot, shotSpawn.position, shotSpawn.rotation);
audio.Play();
}
}
}