I am working on a 2d hexgrid-tbs with 3d terrain.
I generate the hexgrid via script and need to check for collisions between the hexes and the underlying map.
This is done when starting the map and i don’t want to keep on checking for collisions.
I have a rigidbody on the terrain and a boxcollider on the hex-mesh.
Basically what i want to do is the following:
// snip code
if ( hex.collidesWith(Ground){
hex.passable=false;
}
//continue code
hex and ground are GameObjects
Is there any way to accomplish this or can i stop trying right away?
Should you need the codes, they’re taken from http://tbswithunity3d.wordpress.com/2012/02/21/hexagonal-grid-generating-the-grid/
Thanks in advance
Sorry for the late reply and thanks for the nudge in the right direction.
I’ve decided to go with a CheckSphere instead of the Raycast for greater accuracy.
The only problem now is that neither Raycast nor CheckSphere will collide with the model/prefab (I’ve tried both model alone and model as prefab) i’m using for terrain.
Changing colliders on the terrain won’t help as well. (I have tried terrain, mesh, rigidbody)
Google only told me that you can’t check for collisions until 1 frame after instantiation of the Object to collide with. Since the terrain is already in the scene and not instanciated this limitation should not apply?
If it does, how do i get Unity to first build the terrain, wait 1 frame and then generate the grid?