private void OnCollisionEnter(Collision collision) { if (collision.collider.CompareTag("Grappable")) { Rigidbody rb = collision.gameObject.GetComponent <Rigidbody>(); if (rb != null) { if (cl != null && cl.getObjName() == name) { rb.velocity = cl.getVelocity() * multiplicator; } else if (cr != null && cr.getObjName() == name) { rb.velocity = cr.getVelocity() * multiplicator; } } } }
private void OnTriggerEnter(Collider other) { if (counterTake > 0f) { return; } for (int i = 0; i < allName.Length; i++) { if (allName[i] == other.name) { if (!startOut) { startOut = true; return; } if (cl != null && cl.getObjName() == name) { cl.drop(); } if (cr != null && cr.getObjName() == name) { cr.drop(); } transform.rotation = other.transform.rotation * Quaternion.Euler(allRot[i]); transform.parent = other.transform; transform.position = other.transform.position + allPos[i]; if (name == "UsbKey") { Destroy(GetComponent <Rigidbody>()); } else { rb.isKinematic = true; } break; } } }