I have grid of instantiated objects, each with a script attached that contains a Vector2 defining the grid position (i.e. x,y). Is it possible to access the game object only by knowing the Vector2 grid coordinates?
It would be very useful to me to be able to send values to functions attached to each object in the grid, based on where it is in that grid.
I have a simple function to convert my grid coordinates into the transform.position of the center of each grid square. I was thinking that one option would be to instantiate an empty object with collider at the transform.position of the grid square in question, and use the hit to return the game object, but I wondered if there may be a more efficient way since this may need to be carried out a at a relatively fast rate.
↧