I have a hexagon prefab, from this prefab my script creates a hexagonal tiled grid map. I am attempting to raycast in a mini map that i have created, and use that to move the main camera. That is all working fine except for one main point. The hexagonal grid does not have a collider, so the camera jumps around fine if you click over other objects, but not the map itself.
I thought the easiest way to do this would be to give the hexagon prefab a mesh collider. That would straight off the bat solve the problem as the raycast would then find each section of the map. However, when the maps can go up to 22,500 hexagons (possibly higher) i’m concerned that performance is going to be an issue having that many mesh colliders, when all they are going to be used for is this raycasting.
My idea to fix this was to create a mesh collider for the hexagonal grid as a whole once it has been created. However it looks like it will be alot more complicated than i originally thought as i’d have to add all the colliders of the hexagons together, before destroying the hexagon’s mesh colliders.
I’m pretty new to raycasting in unity, and indeed unity itself, I was desperately hoping that there might be a simpler way within unity to allow my ray to detect the Hexagon grid.
Is there hope? Or do i need to create mesh colliders on the hexagon, combine all of the colliders into a grid collider and then delete the hexagon colliders?
Thanks in advance guys.
- Edit, not sure why this didn’t occur to me before but have decided to try create a plane behind the grid instead, my question now is, is it possible to match the dimensions of a plane to that of the grid?