- Home /
Colliders not working
If I use custom or compound colliders, Unity does not allow to attach same type of two colliders and if I attach different collider to different child game objects and attach a rigidbody to parent game object in this case It throws Error "Script is trying to access collider blah. blah blah. " . Any Suggestion
Answer by Davidovich · Jan 04, 2013 at 11:51 AM
It sounds like the script is trying to access the collider on the main GameObject, but this doesn't exist because it's attached to the child GameObject as part of the compound collider.
What you will need to do is change your script to get the collider attached to the child game objects and the refer to this instead of trying to access the one that doesn't exist.
EG.
// Get the child object which contains the collider.
var childGameObject = gameObject.GetComponent("childGameObject");
// Refer to the collider on this object.
Debug.Log(childGameObject.collider);
It's hard to really help out any more without seeing the specific code and error message.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090352im_/https://answers.unity.com/themes/thub/images/avi.jpg)