Search Unity

RaycastHit.collider returns parent object instead of object hit

Discussion in 'Editor & General Support' started by hyown, May 16, 2019.

  1. hyown

    hyown

    Joined:
    May 16, 2019
    Posts:
    1
    I've made a gun that shoots with raycasts and I tried making different damages based on where it hit. I have a capsule as the parent object and the body, and then I have the head which is a sphere as a child of the capsule. I'm using hit.collider.name (and tried hit.collider.transform.name) but in the debug.log they both return the parent object.
    -Also parent object has a rigidbody, child does not.

    Unity version 2019.1.0f2
     
    Last edited: May 16, 2019