CoronaRun/Assets/Scenes/scripts/corona.cs
2025-01-19 22:16:28 +05:30

37 lines
920 B
C#

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);
}
}