Snap enemy with navmesh to 90 degree angles

Godot Version

4.2

Question

I want to create an enemy that can only move at 90 degree angles and uses a navmesh. I wanted to do this by snapping their direction vector to 90 degree angles, but I couldn’t figure out how to do this. The closest I could get was 45 degree angles with the snapped() function.

The best way of doing this is probably not using a navmesh, but instead Astar3D since my scene does use gridmaps. How I’ll do this, I still have no idea, but I’ll figure it out eventually.