/// <summary> Create a Physics Joint between a grabable and a snapZone. </summary> /// <param name="grabable"></param> /// <param name="snapZoneBody"></param> /// <param name="breakForce"></param> public void CreateJoint(SG_Grabable grabable, Rigidbody snapZoneBody, float breakForce) { if (this.myJoint == null) { if (grabable.physicsBody != null) { this.myJoint = grabable.physicsBody.gameObject.AddComponent <FixedJoint>(); this.myJoint.connectedBody = snapZoneBody; this.myJoint.enableCollision = false; this.myJoint.breakForce = breakForce; } } else { SG_Debugger.LogError("Multiple Physics connections to my Properties. Wrong index!"); } }
/// <summary> Begin the interaction between this object and a GrabScript. </summary> /// <param name="grabScript"></param> /// <param name="fromExternal"></param> public bool BeginInteraction(SG_GrabScript grabScript, bool fromExternal = false) { if (grabScript != null) { if (this.isInteractable || fromExternal) //interactions only possible through these parameters. { bool begun = this.InteractionBegin(grabScript, fromExternal); if (begun) { this.originalDist = (grabScript.grabReference.transform.position - this.transform.position).magnitude; this.OnInteractBegin(grabScript, fromExternal); return(true); } } } else { SG_Debugger.LogError("ERROR: You are attempting to start an interaction with " + this.name + " with grabscript set to NULL"); } return(false); }