mirror of
https://github.com/kuhyx/praca_magisterska.git
synced 2026-07-04 13:43:05 +02:00
19 lines
422 B
C#
19 lines
422 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class EnemySpawner : MonoBehaviour
|
||
|
|
{
|
||
|
|
public GameObject enemyPrefab;
|
||
|
|
public float spawnInterval = 1f;
|
||
|
|
public float xRange = 8f;
|
||
|
|
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
InvokeRepeating("SpawnEnemy", 1f, spawnInterval);
|
||
|
|
}
|
||
|
|
|
||
|
|
void SpawnEnemy()
|
||
|
|
{
|
||
|
|
float xPos = Random.Range(-xRange, xRange);
|
||
|
|
Instantiate(enemyPrefab, new Vector3(xPos, 6, 0), Quaternion.identity);
|
||
|
|
}
|
||
|
|
}
|