Portal-In-Unity icon indicating copy to clipboard operation
Portal-In-Unity copied to clipboard

Why is the movement reversed when seen in the portal!

Open dcmrobin opened this issue 3 years ago • 2 comments

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!

dcmrobin avatar Aug 13 '22 12:08 dcmrobin

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;
	}
}

evan-roos456 avatar Jun 03 '23 21:06 evan-roos456

Thanks!

dcmrobin avatar Jun 04 '23 16:06 dcmrobin