Scene 3 - Prevent Partial Hexa?


The above screenshots show some attempts to mess with MapNav2’s projections onto terrain. I think I mostly understand how it works, but I’m curious as to what causes the above two phenomena. The latter I’ve figured out, somewhat. It seems like changing the max node height and clicking Lift Grid will raise the projectors over the terrain. My question here is if there is a downside to raising the grid too high, and, if not, why not just automatically start it quite high? It’s pretty unlikely that a terrain will be laid atop the terrain you want to project on, after all.

As for the first screenshot, it would certainly be possible to only generate a grid the size of the terrain you want to have the grid on it, but in the example scene, the grid is larger than the terrain, but not all the nodes project a hex. How do I achieve this effect? Is it related to node data? Do I set that via scripting while creating the grid, or is there a way to do it in Unity?


Sorry to add on a somewhat unrelated question, but as it pertains to scene 3. . . .

When generating a grid, I can get the labels to show up, but not the outlines as in scene 3’s example. In the first screenshot in the OP, you can see in the Scene view, the cyan/grey hexagons showing where the hexes will appear. For me, the corresponding labels appear if zoomed in close enough, but not the hexagons.

(Leslie Young) #3

re projector

Not sure what is happening there. If you are going to use projectors just use the sample as a sample and set up projectors according to latest docs. Could be that new shaders are needed and the ones I include are no good for latest Unity version. Get whatever is latest from the Unity examples/ standard assets,

partial hexa

tldr; choose “check valid” for “extra precision” in height tool options before you press execute.

The easiest way to deal with that problem in shot 1 is to create a smaller grid which fits inside the terrain boundary. You may also move the MapNav object (change its world location) so its nodes overlap nicely. It does not have to be at 0x0x0.

The other option would be to modify the code which determines if a hexa is invalid. That would be in the Height Tool which makes calls to MapNavHexa.AdjustToColliders() (around line 366) in MapNavHexa.cs

You will see a ray is cast down the centre of the node and it just happens that the edge of the terrain is on these centres and therefore the node is included.

One would need to calculate the position of the 6 corners of the node and cast rays down those, as an addition if centre cast succeeded, to makes sure all 6 are valid.

But, looking at my code again, it seems I did include an option for this (see line ~390). You just need to select one of the “extra precision” options in the Height Tool options; for example “check valid”.


Ok, both of those were helpful, thank you.

How about the issue of the outlines not drawing in Scene View? I searched the project to see if maybe you were using Debug.DrawLine or something, but nothing I checked turned up results. Do you happen to recall what method/etc you were using to create the cyan outlines in the scene view, as shown in the first picture in the OP?

(Leslie Young) #5

Which are not drawing? The grey ones shows nodes which are considered “invalid”.

I am using Gizmos to draw them. See MapNavHexa.OnDrawGizmos().
So the MapNav component should be expanded in inspector and the “show nodes” at bottom of inspector should be on.