Udon Graph NavMesh.SamplePosition Bug check?

I may have found a bug, but I need someone to check my graph to make sure I’ve put it together correctly.

Here is an example of the Udon Sharp code I’m duplicating, it seems to work in udon sharp.

public class SamplePosition : UdonSharpBehaviour
{

    public GameObject MovePoint;
    public GameObject VectorPoint;
    public float Distance = 1;
    private Vector3 Destination;
    private Vector3 Vector = new Vector3(20, 0, 20);

    void Start()
    {
        Destination = CalculatePosition(Distance,Vector);
        MovePoint.transform.position = Destination;
        VectorPoint.transform.position = Vector;
    }

    private Vector3 CalculatePosition(float dist, Vector3 dir)
    {
        NavMeshHit hit;

        NavMesh.SamplePosition(dir, out hit, dist, NavMesh.AllAreas);

        return hit.position;
    }

}

In Udon Graph I always get a position output (Destination) of 0,0,0. I don’t know if it’s a problem with graph or I just set it up wrong. Can someone check my work?

Udon Graph:

application/vnd.unity.graphview.elements AO1a224byRH9FWGe2UR3dfVNgB8Uey/CrjdG5NVLbAh9VZilyAUvziqSvywP+aT8QmpIUaTJMT2QRS1pSBIEieTMdFedU3Wqqv/3n//eVB98f5qr47/fVGXa7//ir+if6tyPej7088Wvg97k+rvBZW+Qz3OcDEey6lTTXqLPgHeKIzhmRdAMi+LMuliYDQCc8yhLDvTh34fj3qQ3HFTHN9Uf1TFzyLuWWyuNdVyD6lTX9KoQznaBbgdSS7AC1MdONRim/OvpqzGtrqI7LX/ed6rSH/7r7r3380+e1xsZz3YyrVf91/BPWvH5fHs3VW8wnvhBzKevqmNONx9PRr3B5d3bVfWx85DLzq7Hk3zVPZu92Dm6GsfhqN8LnaPzPBrTpl9gl9ffnaOX0/5kOsovBnk6Gfl+5+jNNPR78ad8/Xb4Wx68CMZ4FZUWTmLm1t2enL71o8s8eZXHk97Az0z4VYv8y3DYz37wuKv83vfH+dtc1y6cOhgOaFXv63V9gW0/0FvzVd8TLoOP0fDMiHiGoeGWWV8SUxxKilpJo+Mz4R7sm3l8ezPsDSZ7COi3o+kzz3bAs/WsZixaYa1mJRO1UBjPvKAk520KyEUOKssGkg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fHX95//D8=

I forgot to include the Max Distance of 1 in SamplePosition box, but if you add that, you get the same result. (fixed)

Log:
NavMeshSamplePositionLog

Visual:

These should be the same point (At vector)as they both are on the navmesh.

You might need to have a NavMeshHit variable and set it after the sampleposition. Then get the position from that variable rather than pulling it directly from the sampleposition into a debug log. Make sure that you don’t try to get anything from it if the bool returns false though.

That produced the same result.

NavMeshSamplePositionLog02

The part I wasn’t sure if I set up properly was this:

Success! Thanks for helping me work though it. That was the issue. I needed an input of the same variable, and not the general defined navmensh hit type.

Heres the working graph code if anyone needs to duplicate:

application/vnd.unity.graphview.elements AO1a23IbuRH9FRWfiSl0o3FzlR8Ue3ejSrxxRV69rF0qAAMoTGhyi6Sc9cr+sjzkk/IL20NKojwca6dkUSFtWS4WrzNA9zndp7vxv//892LwLozP8+DJzxeDcj4e/xje8ovBSZiNQhzn058mo8X77yZno0k+yWkxnanBcHA+qvk7GLyWhF44iEZQ0VI4n4pwEVFKmVTJkb/8y3Q+Woymk8GTi8GvgycCtcVKSS8dSgWoh4P3/C4oMpU2FpTjB2f1x+FgMq3zT0fP57y4AV9o/f/NcFDG039ffvZm9c2TZh/z5UbOm0X/Lf6TF3yy2t3FYDSZL8Ik5aPngyeSLz5fzEaTs8uPB4OPw7v87Pj9fJHfVsfLN4cHb+dpOhuP4vDgJM/mvOenVMnmb3jw7Hy8OJ/lp5N8vpiF8fDg5Xkcj9Jf8vtX03/lydNobdBJG/CKsnT+w+HRqzA7y4vneb4YTcLSgl+0yD9Np+McJve7yu/DeJ6/znVtw6mT6YRX9aZZ1x+Q7Qf+aLXqa75lDClZmQXzzgqy0gkXSi20xFIno5U16ZFvd3XNKrq9nI4mix3E86vZ+SPNtkCzdk6zjhw4Z0TJzCwCG0QATnHB1ZEk5Kiz6uCY0p42OYbS24ovB6BRkXrk2MraXyeOd3VdO5fGVPDeByRRUCVBWtfCW4uiRJOcRpnRyMc0dlfXvJi+y49J7Nsi2eHRj+Hdizz/x59HN9Uiaq0DCa0yV2dgM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