Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Destroy button only destroys the last clone of object

$
0
0
Hello, I am working on a 2d isometric grid building system, and I have encountered a problem with destroying already placed objects. So I have a prefab with a panel and buttons, one button for placement and the other for destroying the prefab clones. It works but only for the prefab clone that was placed last. If I try to destroy others I get this error "MissingReferenceException: The object of type 'Building' has been destroyed but you are still trying to access it.". Here is the code I use to instantiate objects public void InstantiateObject(GameObject gameObject) { if(!objectUnplaced) { if (canBePlaced) { current=Instantiate(gameObject,Vector3.zero,Quaternion.identity).GetComponent

Viewing all articles
Browse latest Browse all 508

Trending Articles



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