I have an enemy AI object that randomly patrols a top down 2d maze(object B) and within this maze are tiles(multiple objects of A). I’m having trouble figuring out a way to change any tiles that is within close distance to the enemy object B. Here is my code:
public Transform blocks;
private void Update()
{
blocks = GameObject.FindGameObjectWithTag("Breakable_Block").transform;
if (Vector2.Distance(transform.position, blocks.position) < 10)
{
blocks.GetComponent<Renderer>().material.color = Color.green;
}
}
Thanks in advance!