public void PickUpPart(GameObject part) { //Debug.Log("Found Object: "+ hit.transform.gameObject.name + "Captn!"); current_obj = part; //Find root; if (current_obj.transform.parent != null){ for (int i = 0; i < 10; i++) { //You won't make an item 10 children deep? current_obj = current_obj.transform.parent.gameObject; if (current_obj.transform.parent == null){ break; } } } ConstConnect cc = current_obj.GetComponent<ConstConnect>(); if (cc != null){ cc.enabled = false; Destroy(cc); } Gondola gnd = current_obj.GetComponent<Gondola>(); Balloon bal = current_obj.GetComponent<Balloon>(); current_item = current_obj.GetComponent<ConstrItem>(); Debug.Log(current_obj); current_item.EnableFadeMode(); if (current_item.colliders.Length >0){ foreach (Collider x in current_item.colliders){ x.enabled = false; Debug.Log("ALL COLLIDERS DISABLED COMMANDER!"); } } else { Debug.LogError("The collider array you refer to is empty!"); } current_item.tint = new Color(1, 1, 1, 0.5f); }
void ReleasePart() { ConstRope rope = current_obj.GetComponent<ConstRope>(); if (hit_obj != null && current_item.connectType != ConstrItem.Connection.NoConnection /*connects*/){ ConnectPart(current_obj); if (mirror_obj != null){ ConnectPart(mirror_obj); HandleItemRelease(mirror_obj); mirror_obj = null; mirr_item = null; } hit_obj = null; foreach (Collider x in current_item.colliders){ x.enabled = true; } } HandleItemRelease(current_obj); current_obj = null; current_item = null; if (rope != null && !rope.reciever && rope.gameObject.GetComponent<ConstConnect>() != null ){ GameObject second = (GameObject) Instantiate(ropeend, rope.transform.position, rope.transform.rotation); PickUpPart(second); rope.target = current_obj.transform; second.GetComponent<ConstrItem>().item_id = item_no; item_no ++; } rot_offset = Vector3.zero; }
void HandleMirroring() { Vector3 mirr_pos = Vector3.Reflect(hit_obj.transform.position - current_obj.transform.position, hit_obj.transform.up); Debug.DrawRay(hit_obj.transform.position, hit_obj.transform.up, Color.blue); if (mirror_obj == null){ mirror_obj = (GameObject) Instantiate(current_obj, mirr_pos, Quaternion.identity); mirr_item = mirror_obj.GetComponent<ConstrItem>(); item_no++; mirr_item.item_id = item_no; } else{ mirror_obj.transform.position = hit_obj.transform.position + mirr_pos; } }