Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is the movement reversed when seen in the portal! #7

Open
dcmrobin opened this issue Aug 13, 2022 · 2 comments
Open

Why is the movement reversed when seen in the portal! #7

dcmrobin opened this issue Aug 13, 2022 · 2 comments

Comments

@dcmrobin
Copy link

Untitled.mp4

why?? the teleportation works, but when I move left, the pic on the render plane moves the other way!

@evan-roos456
Copy link

evan-roos456 commented Jun 3, 2023

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

@dcmrobin
Copy link
Author

dcmrobin commented Jun 4, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants