public Transform playerCamera;
public Transform portal;
public Transform otherPortal;
float myAngle;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
Vector3 playerOffsetFromPortal = playerCamera.position - otherPortal.position;
transform.position = portal.position + playerOffsetFromPortal;
float angularDifferenceBetweenPortalRotations = Quaternion.Angle(portal.rotation,otherPortal.rotation);
if (myAngle == 90 || myAngle == 270)
{
angularDifferenceBetweenPortalRotations -= 90;
}
Quaternion portalRotationalDifference =
Quaternion.AngleAxis(angularDifferenceBetweenPortalRotations, Vector3.up);
Vector3 newCameraDirection = portalRotationalDifference * playerCamera.forward;
if (myAngle == 90 || myAngle == 270)
{
newCameraDirection = new Vector3(newCameraDirection.z * -1, newCameraDirection.y,
newCameraDirection.x);
transform.rotation = Quaternion.LookRotation(newCameraDirection, Vector3.up);
}
else
{
newCameraDirection = new Vector3(newCameraDirection.x * -1, newCameraDirection.y,
newCameraDirection.z * -1);
transform.rotation = Quaternion.LookRotation(newCameraDirection, Vector3.up);
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}