x


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 on.

The geometry has the static flag off The geometry has the static flag off.

more ▼

asked Jul 31 '12 at 10:49 PM

ricardo.ch gravatar image

ricardo.ch
1 1 3

can you post script that you use?

Aug 02 '12 at 09:06 PM ScroodgeM

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.

Aug 02 '12 at 09:12 PM ricardo.ch

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?

Aug 03 '12 at 06:31 AM ScroodgeM

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.

Aug 03 '12 at 05:02 PM ricardo.ch
  • 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?

Aug 04 '12 at 09:54 AM ScroodgeM
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Aug 03 '12 at 11:45 PM

ThermalFusion gravatar image

ThermalFusion
676 1 5

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.

Aug 04 '12 at 12:07 AM ricardo.ch
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2494
x1693
x276
x116

asked: Jul 31 '12 at 10:49 PM

Seen: 391 times

Last Updated: Aug 04 '12 at 09:54 AM