Get Mesh from physicsShape

Hi there,

I’m looking into possible solutions for constructing a navmesh in DOTS. I think it will be possible if I can translate a RigidBody/PhysicsCollider with meshcollider to UnityEngine.Mesh. Is this possible? If so, how can it be done?

Regards

There is a CreateRenderMeshFromCollider function in SceneCreationSystem.cs which hijacks one of the DebugDraw functions. It’s not fast but it might suit your needs.

Thanks, that’s good to know. What I ended up doing was to collect all vertices in the GetLeaves() method. Its inconvenient but works. Why don’t you expose the internal mesh of mesh colliders?

By navmesh you mean your own navmesh implementation or Unity’s?

In either case going through Unity.Physics is really doing this the hard way. You bake physics colliders from a source, just use that source. Or in the case of box/sphere/capsule just use the matching primitive mesh.

I’m using unity’s implementation. I’ve already got it sort of figured out for baking from colliders. The advantage compared to using the rendermesh, is that I can have complex render meshes but use simple colliders for navigation. Besides, my movement is based on physics so it makes sense to use the colliders for this.