- Home /
Parent Script accessing Child components
Hello, I'm working on a game which uses guided missiles to destroy planes, to do this each plane's parent has a small box collider and a child which has a large sphere collider when the missile enters the large sphere collider it uses transform.LookAt to hone in on the plane. In the plane script (on the parent object with the box collider) when the missile hits the box collider it triggers the plane to explode (in theory) by using this
void OnTriggerEnter (Collider other)
{
if(other.gameObject.tag == "HGP_64")
{
HeavyMissileDamage();
}
}
However what's happening is the script above on the parent object is using the sphere collider on the child object to detect the missile therefore resulting in the plane exploding way before the missile hits. How can I stop the parent from accessing the childs collider?
Answer by edcarlo · Jan 16, 2014 at 12:20 AM
try to create a layer name for plane and for missle, then uncheck the layer collision matrix between plane and missle.
Your answer
Follow this Question
Related Questions
Have child ignore parent's tag? 1 Answer
OnTriggerEnter not being called with multiple colliders 1 Answer
Trouble with triggers and colliders 1 Answer
Make a simple tree 1 Answer