Control height of a specific node?


Sorry for all the questions! I feel like I’ve just about got what I need out of this script, though, after the scope of my project changed somewhat. Now, the thing I’m wondering is if there is a way to set a specific node to have a specific height, in a hex grid. I tried messing with Hexa.cs but I couldn’t quite figure out what to edit and with which values.

I know exactly what height I want each node, and I think the easiest way to reference each one is obviously a for loop, but where would I put this loop and what value would I change?

(Leslie Young) #2

Use NodeAt to get the node you want to mess around with. MapNavNode n = map.NodeAt<MapNavNode>(q, r);

You could for example set the Y in MapNavNode.localPosition. Note that this is normally manipulated during grid creation time so it should be save to for your to make changes to locaPosition at runtime. Functions like ChangeGridHeight, SmoothOut, and so on normally changes it. So if you do use these at runtime then it will be changed.

It might be best to work within your map’s node height stepping and also to set “H” in node since that might be used by some other functions like OnNodeCostCallback which needs to know how high the node is in “steps” relative to other.

node.h = 2;
node.localPosition.y = node.h * map.nodeHeightStep;