Help for Camera Manipulation for different rooms

Hey there!

I was wondering how to make a Camera change when you walk in a room like the game NullWork: https://www.roblox.com/games/4486383608/Nullwork

I’m also wondering how to tween the transitions between the Cameras.

If you can help that would be Wonderful! :grinning:

Ask me for any Questions!

Roblox has a cameraType like this already so you could you use it

camera.CameraType = Enum.CameraType.Watch

How can I use that Camera type? could you link something?

I corrected it but anyways here is it Camera | Roblox Creator Documentation
also i’m not completely sure if this would work in this case but you could try or else I could look with a solution using CFrame

He’s probably be better off creating different BasePart instances which represent cameras and then setting the “CameraSubject” property of the “Camera” instance to those proxy cameras.

so cameraSubject rotates the camera to the subject without needing the use of cframe?

No, it just focuses the camera on a different part as opposed to the camera focusing on the player’s character’s humanoid.

Do you have a camera script or are you using default camera?

I do

Script 1:

local char = script.Parent
local root = char:WaitForChild(“HumanoidRootPart”)
local cam = workspace.CurrentCamera
local Cam2 = workspace.Cam2

local customCameraEnabled = false;

local function enableCustomCamera()
char.HumanoidRootPart.CFrame *= CFrame.Angles(0,math.rad(-180),0)
customCameraEnabled = true
game:GetService(“RunService”):BindToRenderStep(“SideCamera”, 201, function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(root.Position + Vector3.new(-10,3,0), root.Position)
end)
end

local function disableCustomCamera()
customCameraEnabled = false
cam.CameraType = Enum.CameraType.Custom
game:GetService(“RunService”):UnbindFromRenderStep(“SideCamera”)
end

–[[

  • Checks if the player is in a custom room (standing on the custom part)

  • @returns {Part|nil}
    ]]
    local function isPlayerInCustomRoom()
    local params = RaycastParams.new()
    params.FilterType = Enum.RaycastFilterType.Whitelist
    params.FilterDescendantsInstances = {Cam2}
    local result = workspace:Raycast(root.Position, Vector3.new(0,-10,0), params)
    if (result) then
    return true
    end

    return false
    end

while wait() do
if (isPlayerInCustomRoom()) then
if (not customCameraEnabled) then
enableCustomCamera()
end
else
if (customCameraEnabled) then
disableCustomCamera()
end
end
end

Script 2:
local char = script.Parent
local root = char:WaitForChild(“HumanoidRootPart”)
local cam = workspace.CurrentCamera
local partThatChangesStuff = workspace.cameraChangerPart

local customCameraEnabled = false;

local function enableCustomCamera()
customCameraEnabled = true
game:GetService(“RunService”):BindToRenderStep(“topDownCamera”, 201, function()
cam.CameraType = Enum.CameraType.Scriptable
cam.CFrame = CFrame.new(root.Position + Vector3.new(5,0,0), root.Position)
end)
end

local function disableCustomCamera()
customCameraEnabled = false
cam.CameraType = Enum.CameraType.Custom
game:GetService(“RunService”):UnbindFromRenderStep(“topDownCamera”)
end

–[[

  • Checks if the player is in a custom room (standing on the custom part)

  • @returns {Part|nil}
    ]]
    local function isPlayerInCustomRoom()
    local params = RaycastParams.new()
    params.FilterType = Enum.RaycastFilterType.Whitelist
    params.FilterDescendantsInstances = {partThatChangesStuff}
    local result = workspace:Raycast(root.Position, Vector3.new(0,-20,0), params)
    if (result) then
    return true
    end

    return false
    end

while wait() do
if (isPlayerInCustomRoom()) then
if (not customCameraEnabled) then
enableCustomCamera()
end
else
if (customCameraEnabled) then
disableCustomCamera()
end
end
end

Its a Local script in StarterCharaterScripts

do this cause its kinda confusing

 ```lua
--script
 ``` -without the space

Sorry Here

Script 1:

local char = script.Parent
local root = char:WaitForChild("HumanoidRootPart")
local cam = workspace.CurrentCamera
local partThatChangesStuff = workspace.cameraChangerPart

local customCameraEnabled = false;

local function enableCustomCamera()
	customCameraEnabled = true
	game:GetService("RunService"):BindToRenderStep("topDownCamera", 201, function()
		cam.CameraType = Enum.CameraType.Scriptable
		cam.CFrame = CFrame.new(root.Position + Vector3.new(5,0,0), root.Position)
	end)
end

local function disableCustomCamera()
	customCameraEnabled = false
	cam.CameraType = Enum.CameraType.Custom
	game:GetService("RunService"):UnbindFromRenderStep("topDownCamera")
end

--[[
* Checks if the player is in a custom room (standing on the custom part)
* @returns {Part|nil}
]]
local function isPlayerInCustomRoom()
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Whitelist
	params.FilterDescendantsInstances = {partThatChangesStuff}
	local result = workspace:Raycast(root.Position, Vector3.new(0,-20,0), params)
	if (result) then
		return true
	end

	return false
end

while wait() do
	if (isPlayerInCustomRoom()) then
		if (not customCameraEnabled) then
			enableCustomCamera()
		end
	else
		if (customCameraEnabled) then
			disableCustomCamera()
		end
	end
end

Script 2:

local char = script.Parent
local root = char:WaitForChild("HumanoidRootPart")
local cam = workspace.CurrentCamera
local Cam2 = workspace.Cam2

local customCameraEnabled = false;

local function enableCustomCamera()
	char.HumanoidRootPart.CFrame *= CFrame.Angles(0,math.rad(-180),0)
	customCameraEnabled = true
	game:GetService("RunService"):BindToRenderStep("SideCamera", 201, function()
		cam.CameraType = Enum.CameraType.Scriptable
		cam.CFrame = CFrame.new(root.Position + Vector3.new(-10,3,0), root.Position)
	end)
end

local function disableCustomCamera()
	customCameraEnabled = false
	cam.CameraType = Enum.CameraType.Custom
	game:GetService("RunService"):UnbindFromRenderStep("SideCamera")
end

--[[
* Checks if the player is in a custom room (standing on the custom part)
* @returns {Part|nil}
]]
local function isPlayerInCustomRoom()
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Whitelist
	params.FilterDescendantsInstances = {Cam2}
	local result = workspace:Raycast(root.Position, Vector3.new(0,-10,0), params)
	if (result) then
		return true
	end

	return false
end

while wait() do
	if (isPlayerInCustomRoom()) then
		if (not customCameraEnabled) then
			enableCustomCamera()
		end
	else
		if (customCameraEnabled) then
			disableCustomCamera()
		end
	end
end
1 Like

I mostly got the Script from here