I am not tryning to develop system just simple bomb that would respwan from along Y-axis. And Player tries to dose.
Here is my code.
using System;
using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
public class SpwanerScript : MonoBehaviour
{
public GameObject bombPrefab;
private float maximum = 2.4f;
private float minimum = -2.3f;
// Start is called before the first frame update
void Start()
{
StartCoroutine(SpawnBombs());
}
private void StartCoroutine(IEnumerable enumerable)
{
throw new NotImplementedException();
}
IEnumerable SpawnBombs()
{
while (true)
{
yield return new WaitForSeconds(Random.Range(0f, 1f));
Instantiate(bombPrefab, new Vector2(Random.Range(minimum, maximum), transform.position.y), Quaternion.identity);
StartCoroutine(SpawnBombs());
}
}
}