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

public class SpawnShield : MonoBehaviour {

    public GameObject shield;
    public Transform spawnPoint;

    private float timeToSpawnShield;
    private float timeToSpawnNext;

    private float timer;

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