public static void ReleaseGrabPoint(GrabPoint grabPoint) { if (grabPoint != null) { RagdollPhysics.DetachRigidbody(grabPoint.baseRigidbody, null, true); ReesetGrabPoint(grabPoint); grabPoint.gameObject.SetActive(false); } }
static GrabPoint BuildDefaultGrabPoint() { GameObject baseG = new GameObject("RagdollPhysicsGrabPoint"); GrabPoint p = baseG.AddComponent <GrabPoint>(); p.baseRigidbody = baseG.AddComponent <Rigidbody>(); p.childRigidbody = new GameObject("RagdollPhysicsGrabPoint2").AddComponent <Rigidbody>(); p.baseJoint = p.childRigidbody.gameObject.AddComponent <ConfigurableJoint>(); ReesetGrabPoint(p); return(p); }
public GrabbedBody(PhysicsHit physicsHit, Quaternion rotation) { this.physicsHit = physicsHit; grabPoint = GrabPoint.GetGrabPoint(); grabPoint.transform.position = physicsHit.averagePosition; grabPoint.transform.rotation = rotation; for (int x = 0; x < physicsHit.hitElements.Count; x++) { connectedJoints.Add(RagdollPhysics.GrabRigidbody(physicsHit.hitElements[x].rigidbody, grabPoint.childRigidbody, false)); } }
static void ReesetGrabPoint(GrabPoint p) { // detach our grab point, if it was attached at all RagdollPhysics.DetachRigidbody(p.baseRigidbody, null, true); p.baseRigidbody.isKinematic = true; p.baseRigidbody.useGravity = false; p.childRigidbody.transform.SetParent(p.baseRigidbody.transform); p.childRigidbody.transform.localPosition = Vector3.zero; p.childRigidbody.transform.localRotation = Quaternion.identity; RagdollPhysics.MakeJointDefault(p.baseJoint, freeRotation: false, Vector3.zero, Vector3.zero, p.baseRigidbody); }