I am aware of this threads existence, and I just have one issue that I cant solve, and its the one provided above. I already looked for the answer in that thread. Do you possibly know how I could achieve this?
The final link in the answer post includes a rbxl file that you can open in studio.
ReplicatedStorage.ViewportWindow seems to be doing what you want, you can dig into that and see what it’s trying to do. At a quick glance it seems like:
It figures out the world-space CFrame and Vector2 size in the :GetSurfaceInfo() method (similar to how I do it in this thread)
Change the FOV of the viewport’s camera to be based on the size of the surface, and the distance of the player’s camera to the surface along the normal axis
local rDist = (camCF.p - surfaceCF.p):Dot(surfaceCF.LookVector)
local newFov = 2*math.atan2(surfaceSize.y/2, rDist)
(The important part you’re looking for) figures out how much to move the viewport frame up and to the left so it looks cropped in the right place:
local rPoint = surfaceCF:PointToObjectSpace(camCF.p)
local sX, sY = rPoint.x / surfaceSize.x, rPoint.y / surfaceSize.y
...
vpf.Position = UDim2.new(vpf.AnchorPoint.x - sX, 0, vpf.AnchorPoint.y - sY, 0)
Does some other stuff to figure out how big the viewportframe should actually be that I don’t quite understand atm:
local scaleX = 1 + math.abs(sX)*2
local scaleY = 1 + math.abs(sY)*2
local scale = math.sqrt(scaleX*scaleX + scaleY*scaleY)
...
vpf.Size = UDim2.new(scale, 0, scale, 0)
There’s more stuff in there. Read through the code and try to understand it, or just use it directly.