How to invert the POV of a camera

I am creating a mirror with a ViewportFrame and i am using a camera for it. I want the POV to be flipped like a mirror instead of seeing the player on the opposite side of the mirror where it shouldn’t be.

Ive looked for anything that would let me flip the ViewportFrame or the camera but nothing worked. Even setting the CanvasSize of the screenGui just makes it disspear.

I can’t properly test my code to make sure the mirror functions until i figure out how to fix this. Ive seen a game called Tunneler by Homade_Meal which is a portal spinoff which contains these, So i know its possible.

Any help would be appreciated!

4 Likes

hm

local viewportFrame = script.Parent
local camera = Instance.new("Camera")
camera.Parent = viewportFrame

-- flip horizontally
camera.CFrame *= CFrame.new(0, 0, -10) * CFrame.Angles(0, math.pi, 0)

this just turns the camera around. I want the POV that gets inputted into the viewportframe to be flipped.
like this:

1
this is the original image.
below is the flipped version.
1 (1)

1 Like

Maybe you can manipulate the camera’s CFrame rotation matrix in such a way that drugs the rendering engine? Not sure if it works for viewport frames, all I know is that it works for the actual ingame camera rendering. However, it does also cause the normals to be inverted as well which makes it look funny:

I forgot the original source for that demo, but here’s the place file that was saved on my PC:
camera distortion.rbxl (266.8 KB)

2 Likes

okay, i will try this. thank you!

1 Like

Side note about the inverted normals, perhaps it can theoretically be fixed by making all of your parts meshes and then turning on double-sided rendering in the properties (???)

2 Likes

so uh. I think i found the part that screws with the system but I don’t understand how to use it. This is the part i found

c.CFrame = c.CFrame * CFrame.new(0,0,0,unpack(matrix))

what does the table matrix do?

okay, i figured it out but the inverted thing is kinda screwey.

1 Like

you uh. Can’t set that property in a script. This won’t work.