void CreateJoint() { RaycastHit hitInfo; GetComponentInChildren <Collider>().enabled = false; if (Physics.Raycast(transform.position, -transform.up, out hitInfo, 1.0f)) { if (hitInfo.collider.CompareTag("Block") || hitInfo.collider.CompareTag("Core")) { FixedJoint joint = gameObject.AddComponent <FixedJoint>(); joint.connectedBody = hitInfo.rigidbody; joint.connectedAnchor = hitInfo.transform.position; joint.anchor = transform.position; joint.breakForce = 900.0f; this.joint = joint; FixedJoint jointHit = hitInfo.collider.gameObject.AddComponent <FixedJoint>(); jointHit.connectedBody = rb; jointHit.anchor = hitInfo.transform.position; jointHit.connectedAnchor = transform.position; jointHit.breakForce = 900.0f; BlockScript script = hitInfo.collider.gameObject.GetComponent <BlockScript>(); if (script != null) { script.AddJointToList(jointHit); } } } GetComponentInChildren <Collider>().enabled = true; }
void CreateJoint(RaycastHit hitInfo) { FixedJoint joint = gameObject.AddComponent <FixedJoint>(); joint.connectedBody = hitInfo.rigidbody; joint.connectedAnchor = hitInfo.transform.position; joint.anchor = transform.position; joint.breakForce = 900.0f; AddJointToList(joint); FixedJoint jointHit = hitInfo.collider.gameObject.AddComponent <FixedJoint>(); jointHit.connectedBody = rb; jointHit.anchor = hitInfo.transform.position; jointHit.connectedAnchor = transform.position; jointHit.breakForce = 900.0f; BlockScript script = hitInfo.collider.gameObject.GetComponent <BlockScript>(); if (script != null) { script.AddJointToList(jointHit); } }