private void OnTriggerEnter2D(Collider2D other) { // if(other.CompareTag("SpawnPoint") && other.GetComponent<RoomSpawner>().spawned == true){ // print("destroy"); // Destroy(transform.gameObject); // } if (other.CompareTag("SpawnPoint")) { if (other.GetComponent <RoomSpawner>().spawned == false && spawned == false) { templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent <RoomTemplates>(); Instantiate(templates.closedRoom, transform.position, Quaternion.identity); Destroy(gameObject); } spawned = true; } }
private void Start() { templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent <RoomTemplates>(); templates.rooms.Add(this.gameObject); }
private void Start() { Destroy(gameObject, waitTime); templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent <RoomTemplates>(); Invoke("Spawn", 0.1f); }