protected override void AttachGrabber(Grabber grabber) { base.AttachGrabber(grabber); FixedJoint joint = GetComponent <FixedJoint>(); if (joint == null) { joint = gameObject.AddComponent <FixedJoint>(); } joint.connectedBody = grabber.GetComponent <Rigidbody>(); var anchor = grabber.transform.position - transform.position; joint.anchor = anchor; joint.breakForce = BreakForce; joint.breakTorque = BreakTorque; }
protected override void AttachGrabber(Grabber grabber) { base.AttachGrabber(grabber); SpringJoint joint = GetComponent <SpringJoint>(); if (joint == null) { joint = gameObject.AddComponent <SpringJoint>(); } joint.connectedBody = grabber.GetComponent <Rigidbody>(); var anchor = grabber.transform.position - transform.position; joint.anchor = anchor; joint.axis = Vector3.one; joint.breakForce = BreakForce; joint.breakTorque = BreakTorque; joint.spring = Spring; joint.damper = Damper; joint.massScale = MassScale; joint.enableCollision = true; }
protected override void AttachGrabber(Grabber grabber) { base.AttachGrabber(grabber); HingeJoint joint = GetComponent <HingeJoint>(); if (joint == null) { joint = gameObject.AddComponent <HingeJoint>(); } joint.connectedBody = grabber.GetComponent <Rigidbody>(); var anchor = grabber.transform.position - transform.position; joint.anchor = anchor; joint.axis = Vector3.one; joint.breakForce = BreakForce; joint.breakTorque = BreakTorque; joint.useLimits = true; var limits = joint.limits; limits.min = MinDistance; limits.max = MaxDistance; joint.limits = limits; }