Advertisement
Placido_GDD

RoomDestroyer

Jan 16th, 2022
900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class RoomDestroyer : MonoBehaviour
  6. {
  7.     public GenerateRooms RoomGen;
  8.     // Start is called before the first frame update
  9.     void Start()
  10.     {
  11.         RoomGen = GameObject.FindGameObjectWithTag("R_Gen").GetComponent<GenerateRooms>();
  12.     }
  13.  
  14.     private void OnTriggerEnter(Collider other)
  15.     {
  16.         if (other.gameObject.tag == "SpawnPoint" || other.gameObject.tag == "GeneratedRoom")
  17.         {
  18.             RoomGen.Rooms.Remove(other.gameObject);
  19.             RoomGen.roomInfos.Remove(other.gameObject.GetComponent<RoomInfo>());
  20.             Destroy(other.gameObject);
  21.         }
  22.        
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement