Quantcast
Channel: Questions in topic: "exception"
Viewing all articles
Browse latest Browse all 470

IndexOutOfRangeException: Array index is out of range / EnemiesSpawner.cs:18)

$
0
0
I am getting this error IndexOutOfRangeException: Array index is out of range. EnemiesSpawner.Spawn () (at Assets/EnemiesSpawner.cs:18) It keeps popping up . When do I spawn my enemies they spawn out fine to me . Here is my script : using UnityEngine; using System.Collections; public class EnemiesSpawner : MonoBehaviour { public GameObject enemy; public Transform [] spawnPoints; public float spawnTime = 5f; void Start () { InvokeRepeating("Spawn", spawnTime, spawnTime); //Calls the "Spawn" function every 10 seconds. } void Spawn () { int spawnPointIndex = Random.Range (0, spawnPoints.Length); for( int spawnCount = 20 ; spawnCount > 0 ; --spawnCount ) Instantiate(enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation); } }

Viewing all articles
Browse latest Browse all 470

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>