# TriangleMeshNode.ContainsPoint not working

I have been trying to use the function ContainsPoint to determine if a point fall within the nav mesh node. However, no matter what I do, it always returns false. The InverseTransform always seems to convert the value to 0,0,0. And event when I use ContainsPointInGraphSpace it still doesn’t work.

I have a node with a position value of 40133, -8996, -75067. I enter into ContainsPointInGraphSpace a parameter of 39000, -8996, -7950. The result is always false. The problem seems to be with the values of the a, b, c vertices which make no sense. They are as follows:
a 158100, 0, 147700
b 170900, 0, 134900
c 170900, 0, 147700

And of course when evaluating against these values, they are always false. The node position itself doesn’t even fall within these values. I’m not sure what would be doing this. Or if it could be because having several graphs in my project that I am testing. The Seeker is only targeting one of these.

Hi

How are you generating this graph? Which version are you using? What code did you use for printing the positions of the vertices?

Also note that you can convert between Vector3s and Int3s using an explicit cast.

``````Vector3 v = (Vector3)someInt3;
Int3 i = (Int3)v;``````

Here is the function where I am using ContainsPointInGraph. I am using a NavMeshGraph for this agent. I created the mesh from a Recast Graph and made some custom changes.

``````public virtual bool FindNavMeshPlane(Vector3 sourcePositon, TriangleMeshNode node, out Vector3 hitPosition)
{
NavMeshHit hit;

//if (NavMesh.Raycast(transform.position, transform.position + down, out hit, areaMask))
//if (NavMesh.FindClosestEdge(transform.position, out hit, areaMask))
Ray ray = new Ray(sourcePositon, Vector3.down);
RaycastHit raycastHit;
if (Physics.Raycast(ray, out raycastHit, PLANE_CHECK_MAX_DISTANCE, vp_Layer.Mask.JustEnvironment))
{
if (node == null)
{
hitPosition = Vector3.zero;
return false;
}
Int3 nodeCorrectedPosition = (Int3)raycastHit.point;
nodeCorrectedPosition.y = node.position.y;
//if (NavMesh.SamplePosition(raycastHit.point, out hit, SAMPLE_NAV_MESH_MAX_DISTANCE, areaMask))
//if (node.ContainsPoint(nodeCorrectedPosition))
if(node.ContainsPointInGraphSpace(nodeCorrectedPosition))
{
//hitPosition = hit.position;
hitPosition = raycastHit.point;
return true;
}
else
{
hitPosition = Vector3.zero;
return false;
}
}
else
{
hitPosition = Vector3.zero;
return false;
}
}
``````

RIght now I actually am taking the Y position from the node class itself, but looking at the class I don’t think that matters.