Camera problems (Camera is looking at spawn after cutscene?)

Ok… I say “Cutscene” here but what is really is, is getting in a locker. When you get in, your camera is fixated to your head, until your in the locker, at which point…

The expected behavior: Your camera stops moving and allows you to look around a little bit by moving mouse around screen

The actual behavior: Camera points at spawnpoint after cutscene plays properly

Script that enables the custcene camera:

local RS = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")

if not game.Players.LocalPlayer.Character then
	game.Players.LocalPlayer.CharacterAdded:Wait()
end

local CutsceneCamera = Instance.new("Camera")
CutsceneCamera.CameraType = Enum.CameraType.Custom
CutsceneCamera.Name = "CutsceneCam"
CutsceneCamera.Parent = workspace

local Camera = workspace.Camera

RS.Visuals.Cutscene.OnClientEvent:Connect(function(inCutscene, Cause)
	if inCutscene then
		Camera.CameraType = Enum.CameraType.Scriptable
		script.CutsceneCamera.Enabled = true
	else
		Camera.CameraType = Enum.CameraType.Custom
		script.CutsceneCamera.Enabled = false
	end
	
	if Cause:HasTag("Locker") then
		task.wait(1.2)
		script.CutsceneCamera.Enabled = false
		script.StationaryCamera.Enabled = true
	end
end)

The actual cutscene camera script:

local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer

local Camera = workspace:WaitForChild("CutsceneCam")

if not game.Players.LocalPlayer.Character then
	game.Players.LocalPlayer.CharacterAdded:Wait()
end

local Character = game.Players.LocalPlayer.Character

workspace.CurrentCamera = Camera

RunService.RenderStepped:Connect(function()
	Camera.CFrame = Character.Head.CFrame
	print(Camera.CFrame.Position)
end)

The script that should keep the camera in place with the mouse moving where you look at, but doesnt:

local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer

local Camera = workspace:WaitForChild("CutsceneCam")

if not game.Players.LocalPlayer.Character then
	game.Players.LocalPlayer.CharacterAdded:Wait()
end

local Character = game.Players.LocalPlayer.Character

workspace.CurrentCamera = Camera

for i = 1, 200 do
	print(workspace.CurrentCamera)
	print(workspace.CurrentCamera.CameraSubject)
	workspace.CurrentCamera.CFrame = Character.Head.CFrame
	task.wait(.2)
end

Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

RunService.RenderStepped:Connect(function()
	Camera.CFrame = Camera.CFrame:Lerp(
		CFrame.lookAt(
			Vector3.new(0, 10, 0), -- Position Vector3
			Player:GetMouse().Hit.Position -- lookAt Vector3
		),
		0.1 -- must be between 0 and 1! to reduce sensitivity, try reducing the number (this is already 10% of the original speed)
	)
end)

Video of the problem:

Any help is appreciated.

BTW! I am going to bed soon after this post. If I don’t reply within like 10 minutes I’m probably asleep and I’ll get back to you tmr

1 Like

update the camera’s CFrame to match the character’s head

I tried that. It seems like the camera is being update to look at the spawn every frame. And if you mean make it update every frame, that won’t work. I want the player to be able to move their camera around slightly by moving their mouse around the screen

Two of the scripts were the same in the post, I fixed it

2 Likes

Ok, first off, the :Lerp function in the last script was setting the position to 0, 10, 0, which obviously isn’t right, so I changed it to the Player’s Head’s position, but that didn’t fix it. I still got the same result. I remove the lerp function and just set the CFrame to the lookat, but now they face the wrong direction inside the locker???

New script:

local RunService = game:GetService("RunService")
local Player = game:GetService("Players").LocalPlayer

local Camera: Camera = workspace:WaitForChild("CutsceneCam")

if not game.Players.LocalPlayer.Character then
	game.Players.LocalPlayer.CharacterAdded:Wait()
end

local Character = game.Players.LocalPlayer.Character

workspace.CurrentCamera = Camera


workspace.CurrentCamera.CFrame = Character.Head.CFrame
RunService.RenderStepped:Connect(function()
	
	
	Camera.CFrame = CFrame.lookAt(
		Character.Head.Position, -- Position Vector3
		Player:GetMouse().Hit.Position -- lookAt Vector3
	)
	
	--[[
	Camera.CFrame = Camera.CFrame:Lerp(
		
		0.5 -- must be between 0 and 1! to reduce sensitivity, try reducing the number (this is already 10% of the original speed)
	)
	]]
end)

Video of the new problem:

I ended up just changing the script to use the same camera the whole time instead of making a new one. That solved the issue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.