> For the complete documentation index, see [llms.txt](https://steijn.gitbook.io/devlogs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://steijn.gitbook.io/devlogs/blewscreen/rezone/movement.md).

# Movement

![Current movement system](/files/WTbu45dKATcTt4BeqMNn)

The game also required a movement system. For this I opted to use the NavMeshAgents. To get the snappy corner movements I made it so the NavMesh generated on a grid shaped object. This provided us with the results we were looking for as displayed in the gif above.

The main difficulty was using the board at a 90 degree angle, which is not possible with the regular NavMesh. This caused me to use [NavMesh building components](https://docs.unity3d.com/Manual/NavMesh-BuildingComponents.html) which ended up being the perfect solution for this.&#x20;

## LineRenderer

To show the pawn’s destination I had to ensure we drew the path. For this I chose to use the LineRenderer and set the NavMesh points to be the same as the LineRenderer points. This will draw a line to where the pawn will move. It took quite some adjusting and was not a great solution, but it did get the desired result. I would not use the LineRenderer for this again. It was not accurate and the corners were not drawn the way we had hoped.

```csharp
public void DrawPath(NavMeshAgent agent, LineRenderer line)     //fill linerenderer with points to render through
{
    if (agent == null || agent.path == null)
    {
        return;
    }
    var path = agent.path;      //set path of navmesh to draw the line
    line.positionCount = path.corners.Length;
    for (int i = 0; i < path.corners.Length; i++)
    {
        Vector3 temp = path.corners[i];
        temp.z = temp.z - 0.1f;         //prevent clipping
        line.SetPosition(i, temp);      //fill position in linerenderer
        if (i == path.corners.Length - 1)   //spawn arrowhead at final point
        {
            ArrowHead(path, i, agent.remainingDistance);
        }
    }
}
```
