I’m looking to create a Teleport Pad in which the Player’s camera is constant -
i.e. When the player Teleports from A to B or vice versa, their Camera adjusts accordingly to be how it would on that side.
I want to do this so movement is persistent, so if the Player enters the pad by holding in D (Walking left) then when they come off the Pad they’ll be walking left from the Pad from it’s direction.
I’ve attached a video below depicting the basic function of the Pad, however I’ve used Blue handles to mark the Front Face of the Parts as this is the way the Player will face when they Teleport.
Unfortunately doesn’t give the desired effect -
I had some help last year on an old topic from a previous account where it was made using .CFrame and I’m sure it was :ToMatrix from the desired part however I stupidly stored my projects on a USB that has now corrupted on me.
Subtract the camera’s position/orientation (separately) from the humanoid’s respective position/orientation, and then once you teleport, you add the stored values to the humanoid’s position and orientation, and the result is your new camera CFrame.
Assuming I understand what you’re looking for correctly, you can just get the camera’s CFrame relative to the root part’s CFrame, then after the teleport, take said relative CFrame and transform it back into world space relative to the root.
local players = game:GetService('Players')
local teleporter = workspace:WaitForChild('Teleporter')
local teleportPart = teleporter:WaitForChild('Teleporter')
local teleportDestination = teleporter:WaitForChild('Destination')
local camera = workspace.CurrentCamera
local deb = false
teleportPart.Touched:Connect(function(otherPart)
local character: Model = otherPart.Parent
if deb or players:GetPlayerFromCharacter(character) ~= players.LocalPlayer then
return
end
deb = true
local root: BasePart = character:WaitForChild('HumanoidRootPart')
local cameraRelative = root.CFrame:ToObjectSpace(camera.CFrame) -- get the camera's CFrame relative to the root CFrame
root:PivotTo(teleportDestination.CFrame + Vector3.new(0, teleportDestination.Size.Y * 0.5 + character:GetExtentsSize().Y * 0.5)) -- the actual teleport
camera.CFrame = root.CFrame:ToWorldSpace(cameraRelative) -- transform back to world space
task.wait(0.1)
deb = false
end)