I am using EgoMoose’s portal system. I modified it to allow me to choose what portal I put down. For some reason when passing through a portal your camera will flick.
I figured out it takes your camera vertical rotation and negatives it. how do I fix this?
code:
function PortalPhysics:MoveRoot(from, to)
local camCF = self.Camera.CFrame
local rootCF, rootVel = self.RootPart.CFrame, self.RootPart.Velocity
local fromCF: CFrame = getSurfaceInfo(from)
local toCF: CFrame = getSurfaceInfo(to)
local cameraOffset = (fromCF:Inverse()) * camCF
local newCamCF = toCF * cameraOffset * Y_SPIN
-- get the twist of the hrp
local swing, twist = swingTwist(rootCF, rootCF:VectorToObjectSpace(UP))
local camRootOffset = rootCF:Inverse() * camCF
local rootOffset = fromCF:Inverse() * rootCF
local newRootCF = CFrame.new((toCF * Y_SPIN * rootOffset).p) * twist * Y_SPIN
local down = math.max(0, toCF:ToObjectSpace(newRootCF * CFrame.new(0, camRootOffset.y, 0)).z)
newRootCF = newRootCF + toCF.LookVector*down
local newVelocity = (toCF * Y_SPIN):VectorToWorldSpace(fromCF:VectorToObjectSpace(rootVel))
self.Camera.CFrame = newCamCF
self.RootPart.CFrame = newRootCF
self.RootPart.Velocity = newVelocity
end
vid: