- Home /
Collider to parent
Hello,
I would like to add multiple meshes to an empty game object, then add a mesh/box collider to the parent. I have tried to add a box, or a mesh collider to it from the inspector, however the resoult wasn't covered the meshes, only a part of them.
How should I do it, or is it even possible?
Answer by krotana · Aug 03, 2011 at 12:06 PM
Hello there, you will have to be more specific? You mean you want to randomly spawn prefabs to a location based on a empty game object by using an array?
You need to use an variable as var anObject:gameObject[];
and then give the settings to what you want the new objects to do.
No.
I have primitive game objects in the scene, and I have parented them to an empty game object. However I don want to add a collider to each of the child object, I would like to add one single big collider to the parent game object,
Answer by krotana · Aug 03, 2011 at 03:36 PM
cant you add a script to the empty game object or go to Component>Physics>Box Collider?
It just adds a box collider with a size (1, 1, 1), without covering the objects.
did you try to increase the size? or you want something that keeps adding?
create a game object variable that counts in all the objects with a tag and then make an update that every time there is a new object with that tag, check the variable size and then create a box collider with the new specs. I am not sure how otherwise I can help you I am no good programer :)
check this link for collision scripts http://unity3d.com/support/documentation/ScriptReference/BoxCollider.html
and I just did this with deleting all objects of the same tag
var array : GameObject[] = GameObject.FindGameObjectsWithTag("taggedObject"); var item : GameObject;
for (item in array)
{
Destroy(item);
}
}
Your answer