-
Notifications
You must be signed in to change notification settings - Fork 193
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
No Collider in Terrain on non-Fixed-Map #3
Comments
Hi, do you have generate colliders turned on in the mesh generation settings, or did you implement your own? If the latter, my system might be interfering with yours. |
I have yours enabled in the mesh generator script. i use your assets without any modification. if i used a fixed map size it works out of the box. i have version 2019.1.0f2 Edit: problem exists in v 2017.4... also |
I have experienced this exact issue in Unity 2019.1.1f1. I believe the reason for the collider not working is that the mesh does not have its bounds calculated by the time you assign it to the mesh collider. I see where you purposefully enable and disable the mesh collider to cause it to update; however, that does not appear to work as expected. meshCollider.enabled = false;
StartCoroutine(EnableCollider());
//meshCollider.enabled = true;
}
meshRenderer.material = mat;
}
private IEnumerator EnableCollider()
{
yield return new WaitForEndOfFrame();
meshCollider.enabled = true;
} |
I'm not sure about that last one, since the same chunk can have its mesh changed many times in Instead, I added this command to Chunk.cs:
And I called it at the very bottom of the UpdateChunkMesh function in MeshGenerator.cs:
It's working in my fork here and here. (However, I need DontGoThroughThings if I'm shooting through landscapes quickly enough.) There's probably a better fix, but this works. |
When updating a lot of mesh colliders, I found it much more efficient to do it with https://docs.unity3d.com/2019.3/Documentation/ScriptReference/Physics.BakeMesh.html https://pastebin.com/5vtND7ap << MeshChunk https://pastebin.com/G4qYGHcP << JobifiedBaking When doing live edit (Updates the collider every frame) i got ~60fps (with force update ~30fps, not editing ~120fps). This uses Unity Job system, so I think it is a bit of overkill if you want a static terrain. I personally use this over "Forceupdate" in my project because of the massive FPS boost. |
I had the idea of using a coroutine as well, unfortunately around 200 units from your start, you no longer update meshes. Also, Sebastian already baked the mesh in the Chunks file. |
Hey, at first: great work.
problem: if i generate colliders automatically in terrain mode and use a non fixed map, the collider isn't active. if I disable and enable the chunk or the meshcollider component of the cunk in playmode, the collider works.
how to fix this?
there a no problems in fixed map mode.
The text was updated successfully, but these errors were encountered: