/// <summary> Set the position of the CameraRig so that the HMD is at the new desired location. </summary> /// <param name="newHMDPos"></param> public void Teleport(Vector3 newHMDPos) { if (this.cameraRig != null) { if (this.camera_eye != null) { Vector3 dPos = this.camera_eye.transform.position - this.cameraRig.transform.position; float newY = ignoreY ? this.cameraRig.transform.position.y : newHMDPos.y; Vector3 newpos = new Vector3 ( newHMDPos.x - dPos.x, newY, newHMDPos.z - dPos.z ); this.cameraRig.transform.position = newpos; } else { this.cameraRig.transform.position = newHMDPos; } this.coolDownTimer = 0; } else { SenseGlove_Debugger.LogError(this.name + ".SenseGlove_Teleport requires access to a CameraRig."); } }
/// <summary> Check if two SenseGlove_Touch scripts are touching the same object </summary> /// <param name="other"></param> /// <returns></returns> public bool IsTouching(SenseGlove_Touch other) { if (other == null) { SenseGlove_Debugger.LogError("Other is Null"); //If this occurs then our grabScript(s) aren't up to scratch. } else if (this.touchedObject != null && other.touchedObject != null) { return(GameObject.ReferenceEquals(this.touchedObject, other.touchedObject)); } return(false); }
/// <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(SenseGlove_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 { SenseGlove_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 void BeginInteraction(SenseGlove_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); } } } else { SenseGlove_Debugger.LogError("ERROR: You are attempting to start an interaction with " + this.name + " with grabscript set to NULL"); } }