stride icon indicating copy to clipboard operation
stride copied to clipboard

Nagivation doesnt work with static meshes

Open YerkoAndrei opened this issue 1 year ago • 10 comments

Release Type: Official Release

Version: 4.2.0.2149

Platform(s): Windows

Describe the bug Nagivation mesh ignore all static meshes

To Reproduce Steps to reproduce the behavior:

  1. Create new project
  2. Add simple navigation configuration as in the official tutorial
  3. Add a plane and some cube
  4. Add static colliders for both
  5. Add infinite mesh to plane
  6. On collider shapes of the cube, add static mesh and reference itself

Expected behavior Navigation mesh should update and use the cube as a wall or obstacle

Screenshots With static mesh 1

With cube shape (how it should look) 2

Additional context

  • Its not a visual problem, characters navigation doesnt work
  • Using a convex hull works good, but it cant be used as a workaround
  • Creating a collider shape asset doesnt work
  • I tried on master and it doesnt work either

YerkoAndrei avatar Jun 13 '24 19:06 YerkoAndrei

If you enlarge the box does the mesh still work with the surface of the mesh? Im curious because I know I used a static mesh at one point for terrain on the old recast nav mesh and it worked for that at least.

Doprez avatar Jun 13 '24 20:06 Doprez

Nope, i cant make it work, i have tried with fbx and glb, so its not that.

Im looking the code and the ColliderShape of the StaticCollider is alway null when using a StaticMesh. I think thats the problem. When the PhysicsComponent try to ComposeShape, it call CreateShape with a null service, wich is only used by Asset and StaticMesh (just these 2 fails). I dont undestand yet what is an EntityManager and why is null, so if someone know someting related please help.

YerkoAndrei avatar Jun 13 '24 22:06 YerkoAndrei

I should be able to look into this a bit this week. The file type should not matter so long as the collider is created, it uses the information from Bullet to create the nav mesh.

Can you also try to downgrade your project to 4.2.0.2122? Im wondering if one of the PRs may have had a larger affect than intended. https://github.com/stride3d/stride/pull/2262

Doprez avatar Jun 24 '24 15:06 Doprez

tried 4.2.0.2188, 4.2.0.2149, 4.2.0.2122 and 4.2.0.2042, not working on any

YerkoAndrei avatar Jun 24 '24 21:06 YerkoAndrei

got it working in my branch https://github.com/Doprez/stride/tree/fix-static-collider-mesh

seems like it has to do with reading asset data that isn't immediately available in editor for some reason.

image

Doprez avatar Jun 29 '24 18:06 Doprez

I did a quick test to make sure it wasn't just working for procedural meshes: image

The only quirk that I can see now is you have to move the physics collider to update the debug mesh the first time.

Doprez avatar Jun 29 '24 19:06 Doprez

its not working on my machine, i tried that 2 weeks ago and it didnt work :( ill try a project from zero

YerkoAndrei avatar Jun 29 '24 19:06 YerkoAndrei

I did some more messing around and a new issue now is the editor full crashes when more than one static mesh is added to the collider shapes.

Doprez avatar Jun 29 '24 19:06 Doprez

So, something thats odd but seems to work is if you create your physics meshes while the navigation stuff is deleted it seems to be fine.

the crash seems to be the fault of NavigationMeshBuilder line 479 when its expecting an updated component that may be out of date or too early? looking into that now.

Doprez avatar Jun 29 '24 20:06 Doprez

Wait.... even in 4.2.0.2188 I can get the static meshes to work. As long as I don't use a procedural mesh at least.

image

The current issues seem to be related to using procedural meshes as the static mesh or trying to create a compound mesh for the static mesh.

Another important thing to note is that there is a bit of lag with how meshes are updated due to transforms being updated after the mesh is built https://github.com/stride3d/stride/blob/904371f6c62e7aec870d12e85dd881f38f5c15c1/sources/engine/Stride.Navigation/DynamicNavigationMeshSystem.cs#L134

The PR I have at least fixes the procedural mesh issue but I am struggling to find the solution for compound meshes, it goes pretty deep.

Doprez avatar Jun 30 '24 01:06 Doprez