Search Unity

Mesh Collider Troubles (Collision Detection)

Discussion in 'Editor & General Support' started by BBrown4, Apr 8, 2014.

  1. BBrown4

    BBrown4

    Joined:
    Feb 13, 2013
    Posts:
    15
    Ok, so I've found a bunch of stuff regarding mesh colliders, but haven't been able to find anything regarding MY problem. The mesh collider is working, just not how I expected it to.

    The problem is when I shoot my turret at the object with a mesh collider on it, it's stopping the "bullets" rather than destroying them, however when I shoot at a cube, it works properly and the bullet gets destroyed when it collides with it. There is probably something simple I'm missing, but I haven't been able to figure out what. Below I have posted an image and my code. If someone could give me a hint as to what's wrong with the mesh collider that'd be great.

    Image:
    $MeshCollisionDetection.png

    Code:
    Code (csharp):
    1. void OnCollisionEnter(Collision collision)
    2.     {
    3.         //TODO: Implement Contact Explosion Effect
    4.         //ContactPoint contact = collision.contacts[0];
    5.         //Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
    6.         //Vector3 pos = contact.point;
    7.  
    8.         Destroy(bullet);
    9.     }
    It's literally straight from the documentation minus the explosion :p, haven't gotten around to making the bullet hit effect yet. I don't think the error is in the code though, seeing as it's working properly with the cube. Sorry I'm kinda new to doing things with bullets and guns in unity :p I appreciate any and all help.
     
    Last edited: Apr 8, 2014