Ok, so I unfortunately hate to post a lot, because through trial and error I can usually get what I want working by reading other peoples help request, and also just working through 10 different ways and eventually finding it.
var speed = 100;
function Awake ()
{
renderer.material.color = Color(Random.value, Random.value, Random.value);
}
function OnCollisionEnter(collision: Collision)
{
if (collision.rigidbody)
{
var fixedJoint: FixedJoint = gameObject.AddComponent(FixedJoint);
fixedJoint.connectedBody = collision.rigidbody;
fixedJoint.breakForce = 1000;
fixedJoint.breakTorque = 1000;
if (collision.gameObject.tag == "Projectile")
{
Destroy(collision.gameObject);
Destroy(gameObject);
Destroy(transform.root.gameObject);
}
}
}
The outcome I want (Which i thought the end line of code would do) is that if i collide with a child object (a sphere in this case) I want both the child and the parent, and the projectile to get destroyed, all 3 gone. Thank you. Everything is working fine: Hit the parent object, both child/parent and projectile gone, but when I hit the child, only the child/projectile die.