AI not sticking to Rotated Navmesh or Grid component

Sorry for another noob question. I have a mesh set up and have placed my AIPath agent on the mesh. What happens is that, when the agent starts moving towards the destination (which is on the inclined mesh), it doesn’t stick to the mesh but rather starts to float above it. The mesh is rotated -7 degrees on the x-axis and the agent is moving in the -z direction (if that makes sense).

Any ideas? I’ve tried and ran into the same exact behavior using a grid and a nav mesh.


You’ll need to implement your own Raycast function to place your AIPath object on the right place on the Y axis.

Use something like this to reposition your character during Update(). The ground mask is used to define what the floor is (Terrain, vehicle, whatever layer you want)

Vector3 RaycastPosition(Vector3 position, float lasty)
    if (raycastingForGroundPlacement)
        RaycastHit hit;
        Vector3 PositionWithOffset = new Vector3(position.x, position.y + 0.5f, position.z);

        if (Physics.Raycast(PositionWithOffset, Vector3.down, out hit, 1f, groundMask))
           position = hit.point;
    return position;


The included movement scripts (except AILerp) use the physics engine for movement, so they will fire a ray downwards to find the ground (assuming the raycast mask is configured correctly). For just 7 degrees tilt it seems it should be pretty close however, but it’s hard to say without a screenshot.

So, is this being used in the MineBotAI script? I don’t see a setup like that in there at all.

The MineBotAI script inherits from the AIPath movement script which includes raycasting code.