using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpawnPowerBullets : MonoBehaviour {

    public GameObject powerBullet;
    public Transform spawnPoint;

    private float timeToSpawn;
    private float timeToSpawnNext;
    private float timer;


	void Start () {
        timeToSpawn = Random.Range(0f, 100f);
        timeToSpawnNext = Random.Range(0f, 100f);
        timer = Time.time;	
	}
	
	void Update () {
        float t = Time.time - timer;
        if (t >= timeToSpawn) {
            transform.position = new Vector3(spawnPoint.position.x, spawnPoint.position.y);
            Quaternion spawnRotation = Quaternion.identity;
            Instantiate(powerBullet, transform.position, spawnRotation);
            timeToSpawn = Time.time + timeToSpawnNext;
        }
	}
}
