0

I am creating a NavMesh in runtime so that I would be able to create a path for the enemy AI, the problem however is that while the NavMesh generation worked outside of AR (I made a script that would build the NavMesh with objects in the prefab). But when I used the prefab inside of the AR in AR Foundation, things got a bit glitchy as even though I made sure that the Nav Mesh Generation is set to run at every frame the prefab existed, the error that "Failed to create agent because it is not close enough to the NavMesh" still exists, even though the error didn't appear when I removed the AR Component.

What's the problem with the NavMesh in AR Foundation?

Here's the image of the AR setup that I got, where I'm supposed to spawn the enemy gameobjects and create the NavMesh.

enter image description here

Here's the prefab that I'm using:

enter image description here

And here's the code for Image recognition: https://hatebin.com/weorcnsegd As well as the main code for spawning the objects and creating the NavMesh https://hatebin.com/jioqrhgbfq

ITmaster
  • 29
  • 7

1 Answers1

0

This error apper when you put an Object not at navMesh but it can be a slightly Below or Above it. Try to use a method SamplePosition after you build the navMesh to find a point on this Mesh and use it to instantiate your Objec or if your Object is already in the scene try Wrap it with obtained Vector3 from SamplePosition. This error apper that this navMesh is not create properly.