News › Forums › RAIN › General Discussion and Troubleshooting › AI moves between disconnected navmeshes
This topic contains 11 replies, has 3 voices, and was last updated by prime 2 years, 7 months ago.
November 9, 2022 at 6:15 pm #5159
The NavMesh in green: https://www.dropbox.com/s/ys6sj611xanm8i1/Screenshot%202013-11-09%2018.54.44.png
The AI starts in a green area, moves towards the player, but always chooses the shortest path through walls (ignoring NavMesh). The NavMesh is generated during runtime.
At the moment I just have one plane as floor. Limiting the floor to walkable areas would probably solve the problem. But still, it seems odd that the AI can walk between NavMeshes?November 11, 2022 at 10:37 pm #5216
In short, the AI moves between disconnected areas in the NavMesh.
Let me know if the picture is bad.November 12, 2022 at 3:03 pm #5228
Probably the same issue a lot of people have been mentioning. Your capsule is likely not “on” the navmesh. If you are using a Unity shape primitive (like your capsule collider or a sphere or cube) the transform is at the middle of the object, which is probably something like 0.5 above the ground. The AI does not consider itself on a NavMesh if its transform is greater than step-up height above the mesh. You want your Body transform to be right on the ground.
To solve the problem, create an empty game object as a new parent for your capsule. Place it directly on the ground (say 0,0,0). Make your capsule a child of the empty object and set its transform so it is on the ground too (for the capsule, that means it will be at something like 0,.5,0 relative to the parent, depending on the capsule size.) Then, change your AI Body to point to the parent, not the capsule. That should fix it.November 12, 2022 at 5:00 pm #5230
My AI is set up exactly as you specify. And it does work perfectly in another level with obstacles/walls that has a premade mesh (so the navmesh is generated before runtime).
Preview collision meshes: https://www.dropbox.com/s/50qak4m8wcchab7/Screenshot%202013-11-12%2017.53.38.png
(Another oddity: in the navmesh screenshot you can see small hill between left and middle room)November 12, 2022 at 7:27 pm #5235
Sorry, you are saying it works with navmeshes created at design time, but not navmeshes created at runtime?November 13, 2022 at 10:30 am #5242
Yes, exactly. And using the “Generate NavMesh” button in the GUI does not help.
The screenshots are from the scene wherein I generate mesh and navmesh at runtime. As you can see in the later screenshots I generate a floor within the walls now instead of one big plane (as in the first screenshot).
November 13, 2022 at 11:12 am #5245
- This reply was modified 2 years, 7 months ago by Chris.
After doing more testing it seems that the AI ignores the navmesh generated at runtime. It simply uses the navmesh created at design time (regardless of how I generate the navmesh at runtime).
Is it possible to tell the AI to update how it sees the navmesh or something similar?November 14, 2022 at 10:28 pm #5322
Shameful bumpNovember 15, 2022 at 12:35 am #5324
After generating the navmesh at runtime, you need to:
navMesh.Name = "whatever"; navMesh.GenerateNavMeshGraph();
and to disable it
navMesh.ResetGraph();November 15, 2022 at 8:50 am #5333
Thanks, it worked!November 17, 2022 at 1:38 am #5374
I can’t make my enemies run around objects anymore. Navmesh doesn’t seem to work in 2.06. Or I am stupid. Anyway, my enemies are running through all objects they walked around in 2.05.November 17, 2022 at 3:09 pm #5386
2.0.6 fixed an issue that was allowing AI to use NavMeshes that were not within a valid height offset. If your AI is not obeying the NavMesh, it most likely means that the Body transform is not on the ground. We posted a video in the Tutorials tab that discusses basic rigging and some problems you might see.
You must be logged in to reply to this topic.