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

public class SimpleSpawner : MonoBehaviour
{
    public GameObject obj;
    float lastTime = 0f;
    public float positionRange = 10f;
    public float speed = 0.5f;
    // Start is called before the first frame update
    void Start()
    {
        lastTime = Time.time;
    }
    // Update is called once per frame
    void Update()
    {
        if(Time.time > speed + lastTime) {
            // spherical volume
            Vector3 newPos = Random.insideUnitSphere * positionRange;
            // rectangular volume
            // Vector3 newPos = new Vector3(Random.value * positionRange,Random.value * positionRange,Random.value * positionRange);
            Quaternion newRot = Random.rotation;
            Instantiate(obj, newPos, newRot);
            lastTime = Time.time;
        }
    }

}
