Z
Z
Zimaell2020-07-30 17:50:20
Unity
Zimaell, 2020-07-30 17:50:20

How to destroy an object by coordinates (or the desired clone)?

I have a grid with x and y coordinates and an object name

private Dictionary<(int,int), string> grid = new Dictionary<(int,int), string>();

when an object is created, the coordinates and name are recorded on it, and a copy of the prefab is also created there
grid[(placeX,placeY)] = Building.name;
Instantiate(Building, new Vector3(placeX, 0, placeY), Quaternion.identity); // в курсе что там Z но у меня такая сетка

Next, I need to remove it from there for example
grid[(placeX,placeY)] = "";
Destroy (???);

But how to remove the copy itself?
The clones are all called the same (for example, Tree(Clone) )...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question