I have several character prefabs created one at a time. The prefabs move on their own through a stage. When a character collides with an object I need them to pick it up (it attaches to a mount in their hierarchy). I have this working just fine except for when the second prefab is created.
If the second prefab touches the object, it becomes attached to the first prefab’s mount instead of the one that touched it. I’m not sure how I am supposed to tell the object which prefab is which. Here is the script I currently have.
var itemTransform : Transform;
var mountTransform : Transform;
function Start()
{
itemTransform = gameObject.Find("Item").transform;
mountTransform = gameObject.Find("Mount").transform;
}
function OnTriggerEnter (theCollision : Collider)
{
if(theCollision.gameObject.tag == "Item")
{
theCollision.transform.parent = mountTransform;
}
}