Is it possible with Unity's pathfinding?

Is it possible in Unity to only allow AI pathfinding agents only to use the X and Y axis? I dont want them to use the Z axis (Its not a 2D game). My game is a platformer and I dont want them moving along the Z axis.

I could of course always set the Z position to 0 BUT that won’t stop the AI from going diagonally which will slow down the AI’s movement.

Is there any possible way to do that?

Add a rigidbody and constrain it on the z axis