private void SetParents() { //parentObjects.Clear(); foreach (AttachmentTriggerController trigger in triggers) { AttachmentPointController attachmentPoint = trigger.GetOverlappingAttachmentPoint(); if (attachmentPoint) { InteractiveObjectController newParent = attachmentPoint.GetOwningObject(); if (newParent && (newParent.grabbed || newParent.attached) && !parentObjects.Contains(newParent)) { newParent.AddObjects(this); newParent.AddMass(mass); parentObjects.Add(newParent); //Debug.Log("Object: " + this.name + " adding object: " + attachmentPoint.GetOwningObject().name + " as a parent object."); //Debug.Log("Parent objects count: " + parentObjects.Count); } } } if (attachedObjects.Count > 0) { foreach (InteractiveObjectController attached in attachedObjects) { attached.SetParents(); } } //SayParents(); }
public void AttachTo(InteractiveObjectController otherObject, AttachmentPointController attachmentPoint) { parentObject = otherObject; parentAttachmentPoint = attachmentPoint; //parentObject.AddObjects(this); Reroot(FindRoot(parentObject)); parentObject.AddObjects(this); Destroy(this.GetComponent <Rigidbody>()); this.GetComponent <Collider>().isTrigger = false; //parentObject.AddMass(mass); attached = true; //Debug.Log(this.name + " attached to " + parentObject.name + ", with root object " + rootObject.name); SetParents(); }
public void AddObjects(InteractiveObjectController objectToAdd) { attachedObjects.Add(objectToAdd); if (objectToAdd.attachedObjects.Count > 0) { foreach (InteractiveObjectController obj in objectToAdd.attachedObjects) { attachedObjects.Add(obj); } } if (parentObject) { parentObject.AddObjects(objectToAdd); } }