using UnityEngine; public class corona : MonoBehaviour { public GameObject obstacle; public float maxX; public float minX; public float maxY; public float minY; public float TimebetweenSpawn; public float DifficultySpeed; public float spawnTime; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { } // Update is called once per frame void Update() { if(Time.time > spawnTime) { spawn(); spawnTime = Time.time + TimebetweenSpawn; } TimebetweenSpawn -= Time.deltaTime * DifficultySpeed; } void spawn() { float randomaX = Random.Range(minX, maxX); float randomaY = Random.Range(minY, maxY); Instantiate(obstacle, transform.position + new Vector3(randomaX, randomaY, 0), transform.rotation); } }