Portal-In-Unity
Portal-In-Unity copied to clipboard
Why is the movement reversed when seen in the portal!
https://user-images.githubusercontent.com/79019086/184493516-65f2e655-0170-4f87-a361-7f1b126a44cd.mp4
why?? the teleportation works, but when I move left, the pic on the render plane moves the other way!
Try this for the portal camera script instead, it should account for the rotational difference of the portal:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PortalCamera : MonoBehaviour {
public Transform playerCamera;
public Transform portal;
public Transform otherPortal;
// Update is called once per frame
void Update ()
{
Quaternion portalRotationDifference = Quaternion.Inverse(otherPortal.rotation) * portal.rotation;
Vector3 playerOffsetFromPortal = portalRotationDifference * (playerCamera.position - otherPortal.position);
transform.position = portal.position + playerOffsetFromPortal;
Quaternion newCameraRotation = portalRotationDifference * playerCamera.rotation;
transform.rotation = newCameraRotation;
}
}
Thanks!