ClampToNavmeshInternalFull Error and 'nextPosition' is going to (NaN, NaN, NaN)

Problem:
Some agents get stuck on mesh and it makes ClampToNavmeshInternalFull null error every frame.
so, they have a path to the target, but can’t move to next node since it fails on that function.

What I found:
I tried to dig down the call stack, and I found the ‘nextPosition’ value is Vector3(NaN, NaN, NaN)
but I couldn’t find where the value is set…

My Settings:
I am using Recast graph, and enemy has RichAI + RVOController (no funnel modifier, simple funnel thing…)
I am using NodeLink2 for climbing up and down. (But I think this is not the problem.)

Any thoughts about this problem?

+) I modified RichAI.ClampToNavmesh to remove the error… but I know this is just bypass temporally.

        protected override Vector3 ClampToNavmesh (Vector3 position, out bool positionChanged) 
        {
        //if (richPath != null) {
		//	var funnel = richPath.GetCurrentPart() as RichFunnel;
		//	if (funnel != null) {
		//		var clampedPosition = funnel.ClampToNavmesh(position);

		//		// We cannot simply check for equality because some precision may be lost
		//		// if any coordinate transformations are used.
		//		if ((clampedPosition - position).sqrMagnitude > 0.001f*0.001f) {
		//			// The agent was outside the navmesh. Remove that component of the velocity
		//			// so that the velocity only goes along the direction of the wall, not into it
		//			var difference = movementPlane.ToPlane(clampedPosition - position);
		//			velocity2D -= difference * Vector2.Dot(difference, velocity2D) / difference.sqrMagnitude;

		//			// Make sure the RVO system knows that there was a collision here
		//			// Otherwise other agents may think this agent continued
		//			// to move forwards and avoidance quality may suffer
		//			if (rvoController != null && rvoController.enabled) {
		//				rvoController.SetCollisionNormal(difference);
		//			}
		//			positionChanged = true;
		//			return clampedPosition;
		//		}
		//	}
		//}

		positionChanged = false;
		return position;
	}

Hi

Which version are you using?
Are you able to replicate the error? If so, would it be possible for you to send me a simple test scene which shows the bug?

Hello, i also have same bug, there occurs devision by 0. For instance in case left part = 0.00005122731 bigger than 0.001f*0.001f , but result difference.sqrMagnitude = 0. Please fix this, also not like 2times (clampedPosition - position)

Hi

I think this has been fixed in the latest beta. Do you think you could try it and see if that works?

yes in 4.1.9 cannot reproduce

1 Like