void HandleClipping() { //handle clipping while player is sliced in portal const float hideDst = -1000; const float showDst = 1000; float screenThickness = linkedPortal.ProtectScreenFromClipping(portalCam.transform.position); foreach (var traveller in trackedTravellers) { if (SameSideOfPortal(traveller.transform.position, portalCamPos)) { // hide mesh on back of portal traveller.SetSliceOffsetDst(hideDst, false); } else { //hide sliced mesh seam while in portal traveller.SetSliceOffsetDst(showDst, false); } // Ensure clone is properly sliced, in case it's visible through this portal: int cloneSideOfLinkedPortal = -SideOfPortal(traveller.transform.position); bool camSameSideAsClone = linkedPortal.SideOfPortal(portalCamPos) == cloneSideOfLinkedPortal; if (camSameSideAsClone) { traveller.SetSliceOffsetDst(screenThickness, true); } else { traveller.SetSliceOffsetDst(-screenThickness, true); } } //handle portal camera position relative to player var offsetFromPortalToCam = portalCamPos - transform.position; foreach (var linkedTraveller in linkedPortal.trackedTravellers) { var travellerPos = linkedTraveller.graphicsObject.transform.position; var clonePos = linkedTraveller.graphicsClone.transform.position; // handle clone of linked portal coming through this portal bool cloneOnSameSideAsCam = linkedPortal.SideOfPortal(travellerPos) != SideOfPortal(portalCamPos); if (cloneOnSameSideAsCam) { // hide mesh on back of portal linkedTraveller.SetSliceOffsetDst(hideDst, true); } else { //hide sliced mesh seam while in portal linkedTraveller.SetSliceOffsetDst(showDst, true); } // make traveller from linked portal properly slice so it looks right if visible from other portal bool camSameSideAsTraveller = linkedPortal.SameSideOfPortal(linkedTraveller.transform.position, portalCamPos); if (camSameSideAsTraveller) { linkedTraveller.SetSliceOffsetDst(screenThickness, false); } else { linkedTraveller.SetSliceOffsetDst(-screenThickness, false); } } }//place portal where clicked