UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"create an enemy spawner"
using UnityEngine; using System.Collections; public class EnemySpawner : MonoBehaviour { public GameObject enemyPrefab; public float spawnTime = 3f; public Transform[] spawnPoints; void Start () { InvokeRepeating ("SpawnEnemy", spawnTime, spawnTime); } void SpawnEnemy () { int spawnPointIndex = Random.Range (0, spawnPoints.Length); Instantiate (enemyPrefab, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation); } }