void OnTriggerEnter(Collider other) { if (other.GetComponent <Rigidbody> () && CameraExtensions.CameraForObject(other.gameObject) != mainCamera && (ignoreRigidbodyTag == "" || !other.gameObject.CompareTag(ignoreRigidbodyTag))) { RigidbodyCollider collider = new RigidbodyCollider(); collider.collider = other; collider.triggerZDirection = (transform.InverseTransformPoint(other.transform.position).z > 0); colliders.Add(collider); } }
void HandleTransition(PortalTransitionObject transitionObject) { if (!this.transitionObjects.Contains(transitionObject)) { if (CameraExtensions.CameraForObject(transitionObject.gameObject) != mainCamera && (ignoreRigidbodyTag == "" || !transitionObject.gameObject.CompareTag(ignoreRigidbodyTag))) { transitionObject.triggerZDirection = (transform.InverseTransformPoint(transitionObject.transform.position).z > 0); this.transitionObjects.Add(transitionObject); } } Vector3 convertedPoint = transform.InverseTransformPoint(transitionObject.transform.position); if ((convertedPoint.z > 0) != transitionObject.triggerZDirection) { if (transitionObject.gameObject.layer == FromDimension().layer) { DimensionChanger.SwitchDimensions(transitionObject.gameObject, FromDimension(), ToDimension()); } else { DimensionChanger.SwitchDimensions(transitionObject.gameObject, ToDimension(), FromDimension()); } transitionObject.triggerZDirection = !transitionObject.triggerZDirection; } if (!isDeforming) // Only deform if the main camera isn't deforming. { Vector3 transformPosition = transitionObject.transform.position; if (Mathf.Abs(convertedPoint.z) < maximumDeformRange) { convertedPoint.z += triggerZDirection ? maximumDeformRange : -maximumDeformRange; transformPosition = transform.TransformPoint(convertedPoint); } meshDeformer.AddDeformingForce(transformPosition, deformPower); } }