praca_magisterska/games/unity/magisterka_1/Assets/EnemySpawner.cs

19 lines
422 B
C#
Raw Normal View History

2025-08-02 19:47:47 +02:00
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);
}
}