Quantcast
Viewing all articles
Browse latest Browse all 2891

Can Someone please explain how to fix this error, I've seen people use random but it won't let me

using System.Collections; using System.Collections.Generic; using UnityEngine; public class SpawnManager : MonoBehaviour { public float SpawnRangeX = 9.7f; public float SpawnPosY = 4f; public GameObject[] EnemyPrefabs; public float SpawnDelay = Random.Range(0, 1); public int RandomNum; public Vector3 SpawnLocation; // Start is called before the first frame update void Start() { SpawnEnemies(); } // Update is called once per frame void Update() { RandomNum = Random.Range(0,EnemyPrefabs.Length); SpawnLocation = new Vector3(Random.Range(SpawnRangeX, -SpawnRangeX), 0, SpawnPosY); } private void SpawnEnemies() { Instantiate(EnemyPrefabs[RandomNum], SpawnLocation, EnemyPrefabs[RandomNum].transform.rotation); } } ![alt text][1] [1]: /storage/temp/197603-error.png

Viewing all articles
Browse latest Browse all 2891

Trending Articles