using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class LevelController : MonoBehaviour { public GameObject artist; public GameObject enemy; public GameObject[] waypoints; private Queue enemies = new(); // Start is called before the first frame update void Start() { spawnEnemy(enemy, waypoints[0].transform.position); } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Instantiate(artist, Camera.main.ScreenToWorldPoint(Input.mousePosition) + Vector3.forward, Quaternion.identity); } } private void spawnEnemy(GameObject enemyIn, Vector3 position) { var e = Instantiate(enemyIn, position, Quaternion.identity); var ec = e.GetComponent(); ec.setWaypoints(waypoints); enemies.Enqueue(e); } }