- Home /
using multiple colliders for a gameObject and it's children
i have a boxer in my game. it has a root boxer gameobject and some children for it's mesh and skeleton (bones). i made two sphere gameobjects with sphere colliders for his fists and another for his head to detect punchs on his head. now i want to move it using raycasting so i attached a big box collider that covers his hole body. this collider is attached to the roo boxer gameobject bu raycasts don't detect it. why? when i replace it with a sphere collider it will be detected but other colliders don't work. this big collider will cover other colliders too and they are inside it. is there any problem in my setup or just unity has a bug or ... i tested some other combinations and changed are child sphere colliders o fists and head to box and then it worked well. the big collider of the root boxer object now works with box and sphere but don't work with capsules. i did not have the time to change all children to capsule but i think then it will work with sphere and capsule for the root object when you raycast. i submited this to UT as a bug but i don't know can i put the bug report link publicly availabl here or not.
Answer by spinaljack · May 29, 2010 at 12:36 PM
Any colliders will block rays, what you need to do is either use physics raycast all to return a list of all hits and find the desired collider with tags or (faster way) put the colliders into different layers and have the rays only detect the relevant layer.
i raycasted using raycastall but it don't detect the collider. iknow the api. as i said it works well with a sphere collider but don't work for a box collider
your question is hard to read, consider posting what scripts you've used