Removing and replacing a Instantiated grid object
I have a self generating grid that generates tile. Each tile has a bool on it with a 15% chance to spawn another tile. What I would like to do, is make the tiles that have the bool marked as true, disappear and be replaced by another tile. I'm not quite sure how to go about doing that? I've looked at many different ways of going about it, but none seem to be doing what it is that I need. Also, this is for C#.
Comment
public GameObject $$anonymous$$ine;
public GameObject BlankSpace;
public CheckBomb CheckBomb;
public int gridX;
public int gridY;
public int spacing = 1;
public GameObject[] GridFill = new GameObject[100];
Vector3 OriginalPos;
void Start()
{
CheckBomb = BlankSpace.GetComponent<CheckBomb>();
for (var y = 0; y < gridY; y++)
{
for (var x = 0; x < gridX; x++)
{
CheckBomb.isBomb = Random.value < 0.15;
Instantiate(GridFill[Random.Range(0, GridFill.Length)], new Vector3(x, y) * spacing, Quaternion.identity);
LoadGameObject();
}
}
}
public void LoadGameObject()
{
if (CheckBomb.isBomb)
{
Instantiate($$anonymous$$ine, new Vector3(gridX, gridY), Quaternion.identity);
}
}
Your answer
Follow this Question
Related Questions
Does the gameobject brush create tiles when painting on a 2d Tilemap? 1 Answer
Copy template object component to dummy objects 0 Answers
Creating a grid that holds objects of different sizes? 0 Answers
Snap object to grid made from cubes during runtime 0 Answers
Create an object on mouse click? 0 Answers