# How to check if unit is moving along a road

I’m not sure how to post images so I’ll try to describe this as best I can.
I have a board made of hexes (not a hex grid, they are 3d objects). Some of these hexes are roads, which give a movement bonus if a unit’s movement is entirely on the road. Each hex has a “HexScript” attached which contains information on whether the hex is a road and where the road exits are (numbered 1-6 starting from the top right and going clockwise).
Movement is done by selecting a path of hexes, then saving it to do the movement later.
I have this code to check whether the next hex being selected is joined to the last hex by road:

``````if (hex.isRoad && RoadCheck(destination, lastHex))
{
}
else
{
}
``````

which calls

`````` bool RoadCheck(GameObject hex, GameObject lastHex)
{
bool returnValue;
Vector3 otherRelativePos = hex.transform.position - lastHex.transform.position;
int value = Mathf.RoundToInt(Mathf.Rad2Deg * Mathf.Acos(Vector3.Dot(lastHex.transform.forward, otherRelativePos) / (otherRelativePos.magnitude * hex.transform.forward.magnitude)));
switch (value)
{
case 30:
print(30);
break;
case 90:
print(90);
break;
case 150:
print(150);
break;
case 210:
print(210);
break;
case 270:
print(270);
break;
case 330:
print(330);
break;
default:
print("error: case is " + value);
returnValue = false;
break;
}
return returnValue;
}
``````

which calls

``````bool RoadFinalCheck(GameObject hex, int num)
{