Search Unity

Weird collision behaviour

Discussion in 'Scripting' started by WooSpringBreak, Aug 3, 2010.

  1. WooSpringBreak

    WooSpringBreak

    Joined:
    Aug 3, 2010
    Posts:
    8
    I need some help with a system I'm scripting. I'm generating tiles out of two triangles, and and recalculating normals and bounds, and I'm updating the mesh used by the MeshCollider using the following code:

    Code (csharp):
    1.  
    2. ... generate mesh ...
    3.  
    4. mesh.RecalculateNormals();
    5. mesh.RecalculateBounds();
    6. MeshCollider col = GetComponent<MeshCollider>();
    7. col.sharedMesh = mesh;
    8.  
    However the player ( a CharacterCollider) will fall through the mesh if it is anything but perfectly flat, and even flat tiles cause physics problems.

    Any help would be greatly appreciated
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    The code you have posted looks basically OK. Can you post the code that generates the mesh? It would be worth checking out.