Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mesh collider on child game object never collides

Discussion in 'Editor & General Support' started by viveleroi, Jun 4, 2018.

  1. viveleroi

    viveleroi

    Joined:
    Jan 2, 2017
    Posts:
    91
    Fixed: I had mistakenly disabled the collider for held objects through code.


    I have a player object (with a rigidbody) and for any "held" items, I spawn them as a child object. Yet for some reason, my collider on the child object (a tool) never fires, until it's "unchilded" from the player.

    On my tool object, I've added a mesh collider, marked it convex, added a rigidbody, and a swing animation. Yet it never "collides" with anything, `OnCollisionEnter` is never called.

    However, when I spawned the tool with the world as a parent and not my player, it falls and collides with my ground (though the handler sits below my ground despite being included in the collider). The collision event fires correctly too.

    - My collider is on the same tool gameobject as the mesh filter/render and rigidbody
    - My collider is marked "convex"
    - My physics settings are set correctly, this tool's layer will collide with the layers I want it to
    - This occurs both when my animation is running and when in an "idle" (no motion) state
    - It only happens when the object is a child of my player

    Could it be a problem with the child rigidbody or child colliders?

    I tried removing the tool's rigidbody and making the collider a trigger, and that doesn't change the results.
     
    Last edited: Jun 4, 2018