Question by
diegodaly · Jan 11, 2021 at 06:07 PM ·
c#vrquaternionportals
I'm adapting the portals from Brackeys to VR, how to stop Z axis from rotating in render texture?
Hello everyeone!
I've encountered several challenges doing this adaptation (newbie) and the first one is that when in Brackeys Tutorial he writes his script to make a camera clone copy the playerCamera position and rotation, the render texture on the portal plane is rolling along with the head movement, and it should stay fixed. It should only copy yaw and pitch.
This is the code for the PortalCamera:
void Update()
{
Vector3 playerOffsetFromPortal = playerCamera.position - otherPortal.position;
transform.position = portal.position + playerOffsetFromPortal;
float angularDifferenceBetweenPortalRotations = Quaternion.Angle(portal.rotation, otherPortal.rotation);
Quaternion portalRotationalDifference = Quaternion.AngleAxis(angularDifferenceBetweenPortalRotations, Vector3.up);
Vector3 newCameraDirection = portalRotationalDifference * playerCamera.forward;
transform.rotation = Quaternion.LookRotation(newCameraDirection, Vector3.up);
}
Thank you all in advance! Diego
Comment