Height tool on a single node


Hi again, I am trying to use the height tool on individual nodes one at a time to make customizing a level easier.

I changed the layer of an individual node and I changed the layer that should be affected by the height tool but when I do this it affects all nodes and when I run the game it crashes unity.

Is there a way to change the height of a single node one at a time?

This would be a neat feature if not! Thank you!

(Leslie Young) #2

There is a bug in the GUILayout_LayerMaskField() function in MapNavEdUtil.cs

Change the function to this and you will be able to select layer(s) other than “Everything”.

public static int GUILayout_LayerMaskField(string label, int mask)
	// Get layers and layer names. This is best I can do for now since
	// caching the names is no use if I can't detect when they are changed
	List<string> names = new List<string>();
	for (int i = 0; i < 32; i++)
		string nm = LayerMask.LayerToName(i);
		if (nm.Length > 0) names.Add(nm);
		else names.Add("Layer " + i);
	// show the mask field
	mask = EditorGUILayout.MaskField(label, mask, names.ToArray());

	return mask;


Hm it still freezes up when I try to run the game after using the height tool on a layer other than Everything ;(

(Leslie Young) #4

Height Tool does nothing at runtime. There must be another problem.
Are you not getting any error messages?


No it just freezes up no error message. I did notice that if I set an individual node to a different layer and then execute the height tool it greys out every other node besides the one that I set to a different layer. So it shows the individual node at the height I wanted but the rest are grey and then If I run unity it freezes up.

I noticed If I uncheck Mark Invalid It doesn’t grey out all the other nodes positions but the only problem is it resets all other nodes to be completely flat.

(Leslie Young) #6

The Height Tool was not created to work on individual nodes. It takes the whole set and adapt the height. Anything not on the selected layers will be reset and also marked invalid if you have the mark invalid option on.

You can hack the AdjustToColliders() to not do the node resets. If you are working with hexa tiles, look in MapNavHexa.cs else in MapNavSquare.cs.

Go to the AdjustToColliders function.

You will see it has an if (Physics.Raycast(... and an else part to that. You want to remove the else since that is what is resetting the nodes.

	grid[idx].h = minNodeHeight;
	grid[idx].localPosition.y = nodeHeightStep * grid[idx].h;
	if (markInvalids) grid[idx].foredInvalid = true;


Cool thank you sir I appreciate it. I have one more question, is it possible to set whatever node to the position you want without the extra offset? I noticed it moves the node/nodes up higher than expected each time you execute the height tool. I want it to just set the height of the node to where the transform position is when I execute it without the extra height offset that gets added. Thank you again for all the help and support.

(Leslie Young) #8

I noticed it moves the node/nodes up higher than expected each time you execute the height tool

Are you also updating tile object positions via the MapNav functions like the examples does? Cause that could cause this to happen.

In example scene 01 this happens because each tile has a capsule collider so the “top” of the collider is not flush with the tile object. Height tool collides with this and uses this as the position of the node. Just an example so it did not matter but now comes along MyHexaMap.OnGridChanged() which also updates the actual tile object and places it at the node position (which is now higher).

Ideally you should draw out your scene and then place a MapNav over it and let the height tool calculate where the nodes should sit according to the what it collides with below each node while checking. Your colliders should be exactly where you need the node to detect them and the node should be placed.


Thank you for the info! I got it working now so making a level should be easy :smiley: