Hello, I have hexagon map where every hexagon has it’s own coordinates - I can calculate those coordinates from a position of mouse click but then I have to find its index to access in an array of hexagons in my Map controlling script. The Hexagon Map is not exactly grid so simple calculation of the index is not possible. I have added an index parameter to every Hex Cell instance - I, therefore, ask you if I can get that instance from calculated coordinates and then access index parameter of that cell to return to that Map Control script.
Hope you understand my question, thank you!
andrew-lukasik’s or bhavinbhai2707’s solutions would work,
Alternatively you could create a Dictionary in order to input the position key and get the referenced object. To create the dictionary you could use a Tag such as “Hex” and use the function GameObject.FindGameObjectsWithTag(“Hex”) to retrieve a list of objects and add them to the dictionary with their position as their key.
Thank you, I haven’t realised that something like dictionaries even existed, thank you. Works fine!