-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Best way to add MeshCollider on every GameObject #137
Comments
Hi @Blocovin , Thanks for reporting. I'd have to try, but maybe it is related to the mesh flags (see this comment) I'll try to test soon |
Thank you for your answer ! |
Good point! |
I fork UnityDraco and I try to set I always got unity errors when I add collider on draco model at runtime
Do you have another suggestion to fix it ? |
Erm....no, nothing obvious. I'll try to look into it next week. |
I found the solution, in Unity 2021.2.X the error is more explicit (https://issuetracker.unity3d.com/issues/physics-dot-raycast-throws-errors-when-used-on-a-navmesh). It's a problem in our mesh, not in gltfast 😆 using System.Linq;
public class CustomGameObjectInstantiator : GameObjectInstantiator {
public CustomGameObjectInstantiator (Transform parent) : base (parent) { }
public override void AddPrimitive (uint nodeIndex, string meshName, Mesh mesh, Material[] materials, int[] joints = null, bool first = true) {
base.AddPrimitive (nodeIndex, meshName, mesh, materials, joints, first);
if (mesh.vertices.Distinct ().Count () >= 3) {
nodes[nodeIndex].AddComponent<MeshCollider> ();
}
}
} |
@Blocovin Great you found a solution! My suspicion is that it isn't performant though (fetching I'd try to avoid this checks in production code. regards, |
@atteneder Indeed you are right it is not performant. 3D models are send by our customer, so unfortunately we must add this check in unity for the moment. We will see if we can clean the mesh from our pipeline. Thank you very much for your help and advice ! |
Hi,
We try to add mesh colliders on every GameObject in CustomInstantiator but we got some errors in unity :
How to avoid errors ?
The text was updated successfully, but these errors were encountered: