Viewportframe SurfaceGui Camera not works

Hello,

local e = Instance.new("Camera",script.Parent.ViewportFrame)
script.Parent.ViewportFrame.CurrentCamera = e
while wait() do
	e.CFrame = workspace.CurrentCamera.CFrame
end

image
I want to make it is like a teleport from RP2 hub but it’s not work the same thing. I want to do it.
https://www.roblox.com/games/5967514178/Ready-Player-Two-Hub?refPageId=9cab2cca-29c0-4ec9-aede-db17b160786b

1 Like

Hello,

How I can make this?

- Best regards, iSyriux

Hello,

I try to make clamp is camera position but it don’t work

local rs = game.ReplicatedStorage
local localplayer = game.Players.LocalPlayer
local rotation = 0
local roundmodule = require(rs.ModuleScripts.Round)
game:GetService("UserInputService").InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.R then
		if rotation>=4 then
			rotation = 0
		else
			rotation = rotation+1
		end
	end
end)
game:GetService("RunService").RenderStepped:Connect(function()
	if script.Parent.Build.Value==true then
		if not game.Workspace.Temp:FindFirstChild(script.Parent.Obj.Value) then
			rs[script.Parent.Type.Value][script.Parent.Obj.Value]:Clone().Parent = game.Workspace.Temp
		else
			localplayer:GetMouse().TargetFilter = game.Workspace.Temp[script.Parent.Obj.Value]
			local xesggo = 0
			local zesggo = 0
			local xer = 0
			local zer = 0
			if (rotation%2==0) then
				xer = game.Workspace.Temp[script.Parent.Obj.Value].PrimaryPart.Size.X
				zer = game.Workspace.Temp[script.Parent.Obj.Value].PrimaryPart.Size.Z
			else
				xer = game.Workspace.Temp[script.Parent.Obj.Value].PrimaryPart.Size.Z
				zer = game.Workspace.Temp[script.Parent.Obj.Value].PrimaryPart.Size.X
			end
			local xes = math.clamp(localplayer:GetMouse().Hit.p.X,game.Workspace.Grounds.Position.X-game.Workspace.Grounds.Size.X/2+xer/2,game.Workspace.Grounds.Position.X+game.Workspace.Grounds.Size.X/2-xer/2)
			local zes = math.clamp(localplayer:GetMouse().Hit.p.Z,game.Workspace.Grounds.Position.Z-game.Workspace.Grounds.Size.Z/2+zer/2,game.Workspace.Grounds.Position.Z+game.Workspace.Grounds.Size.Z/2-zer/2)
			if not (game.Workspace.Grounds.Position.X % 2 == 0) then
				xesggo = -1
			end
			if not (game.Workspace.Grounds.Position.Z % 2 == 0) then
				zesggo = -1
			end
			print(xesggo)
			print(zesggo)
			local cf = CFrame.new(roundmodule.round(xes,2)+xesggo,game.Workspace.Grounds.Position.Y+game.Workspace.Grounds.Size.Y/2+game.Workspace.Temp[script.Parent.Obj.Value].PrimaryPart.Size.Y/2,roundmodule.round(zes,2)+zesggo) * CFrame.fromEulerAnglesXYZ(0, math.rad(rotation*90), 0)
			game.Workspace.Temp[script.Parent.Obj.Value]:SetPrimaryPartCFrame(cf)
		end
	else
		localplayer:GetMouse().TargetFilter = nil
	end
end)

- Best Regards, iSyriux

Get the rotational matrix of the camera and apply it to a predefined cframe at the desired offset, then apply that to the viewport camera’s cframe

Hello,

I don’t know what you are talking about but it is not the point to clamp camera cframe, because I want to do what I want to did in the top post

- Best regards, iSyriux

If you look in the second video you showed us, the size of the item(s) presented in the viewport frame doesn’t change, so it’s applying the rotational matrix to the cframe at the desired offset, otherwise depth would play a role.

Hello,

Can you explain? I don’t know what you are mentioned anything is

- Best regards, iSyriux

They are a slightly-modified version of the portal made by EgoMoose and I think EmilyBendsSpace also helped make it.
here’s the link to the original (open sourced):
https://www.roblox.com/games/3638523142/Teleportation-portal-demo

2 Likes