- Home /
Manual Collision Mesh fails on Static Geometry
I have a script that creates a MeshCollider from the mesh I have, by removing any triangles which have an normal angle with World Up larger than a threshold.
So far, this is working correctly, the problem comes in when I set my pieces of geometry to be static. After I do that, the generated MeshCollider is displaced by a certain amount, and my character, predictably, doesn't collide with the platform.
Is there something I should calculate differently when dealing with static objects? There seems to be an offset that is being used for my geometry, which I have not set up.
Any help will be appreciated, thanks!
Red debug draw represents the generated MeshCollider
The geometry has the static flag on.
The geometry has the static flag off.
It's pretty much the same script mentioned here:
http://answers.unity3d.com/questions/236313/one-way-collider.html
I just added some debug drawing.
i did the following: - imported a model in unity - assigned a mesh collider to ir - attached a script from your link - marked object as static - tried to move and rotate object
collider does not displaced from rendering mesh
how can i reproduce the problem?
Create duplicates of the model with the script and collider and move them, then set them as static and run the game. Pause the game and click on the models to see where the collisions lie.
created a script that duplicates model from scene, model has mesh collider, after duplicating it was moved.
then models was marked as static
it's script from link above on models.
game was started and paused
colliders are at correct position.
can you pack a simple scene with this problem to unitypackage?
Answer by ThermalFusion · Aug 03, 2012 at 11:45 PM
There's probably an issue with the actual meshes being changed when turned into static. Perhaps you can make them static after you have generated the colliders. http://docs.unity3d.com/Documentation/ScriptReference/StaticBatchingUtility.html
What I'm guessing is that, when turning them geometry static, the instances store an offset from the one taken as the original instance. That offset must be wrong.
I'll try to use Combine after all of them have their collision geometry generated.
Your answer
Follow this Question
Related Questions
Collider not working with dynamic mesh 0 Answers
How do I detect a collision between two colliders? 2 Answers
Multiple colliders on one object? Or changing variables on a specific clone. 1 Answer
Correct position of overlapping meshes 0 Answers
Is there ANY possible way to use a mesh collider(without convex) with a rigidbody? 1 Answer