Camera Position Only Changes Once

I would like to have a start screen that changes to a cutscene when you press play, but even though the camera does go the the start menu position, it refuses to move after that.

I have tried setting camera type to scriptable, and searching for other people having problems like this, but I haven’t found anything. I am really new to camera positions (I just followed the side-scroller tutorial and edited it), so it may just be something really obvious that I didn’t see.

Script:

local RunService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local BEvent = game.ReplicatedStorage.PressPlayBindableEvent
local CamNum = 1

local function IntroCam()
	camera.CameraType = Enum.CameraType.Scriptable
	local rootPosition = Vector3.new(-57.929, 0.537, 59.982)
	local cameraPosition = Vector3.new(-48.44, 11.796, 73.57)
	camera.CFrame = CFrame.lookAt(cameraPosition, rootPosition)
end

local function Scene1()
	camera.CameraType = Enum.CameraType.Scriptable
	local rootPosition = Vector3.new(-53.32, 26.54, 110.48)
	local cameraPosition = Vector3.new(-53.17, 33.5, 110.48)
	camera.CFrame = CFrame.lookAt(cameraPosition, rootPosition)
end

local CamNames = {IntroCam, Scene1}

BEvent.Event:Connect(function(num)
	CamNum = CamNum + 1
end)

RunService:BindToRenderStep(CamNames[CamNum], Enum.RenderPriority.Camera.Value + 1, CamNames[CamNum])

I am using a list to store the names of the functions so I can easily trigger different cutscenes.

could be a studio bug, have you tried doing task.wait() on it?

I tried putting task.wait() in the functions, but it had no effect. Did you mean to put it somewhere else?

I mean to put it before and end after the line that changes the camera pos. if this is somewhere in the functions then sorry, i didn’t really read it.

alternatively, instead of changing the camera position, you could change the camera subject.
image
this is usually what i do although i think it is slightly less processing power to change the pos.

I don’t have any experience with setting CameraSubject, but I will try it.

Btw, I just found out the if I change a value in the first function, (IntroCam), then the camera position will change, the problem is just that it wont switch to the second function for some reason.

1 Like

Is that script on the server side? You should move the player camera from a local script
Besides that, im not sure, but i think you cant use the RunService:BindToRenderStep() that way…

Try:

BEvent.Event:Connect(function(num)
   RunService:BindToRenderStep(CamNames[CamNum], Enum.RenderPriority.Camera.Value + 1, CamNames[CamNum])
--we can remove the if i think but i will leave it there
   if CamNum > 1 then
      RunService:UnbindFromRenderStep(CanNames[CamNum])
   end

   CamNum = CamNum + 1
end)

--we still need this
RunService:BindToRenderStep(CamNames[CamNum], Enum.RenderPriority.Camera.Value + 1, CamNames[CamNum])

Yep the script is on the server side

I forgot to say that I found a solution by having the function not change and instead to have the values in the function change.

Here is the fixed code:

local RunService = game:GetService("RunService")

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera
local BEvent = game.ReplicatedStorage.PressPlayBindableEvent
local CamNum = 1

local rps = {-57.929, 0.537, 59.989, -54.42, 26.54, 110.48}
local cps = {-48.44, 11.796, 73.5, -54.37, 32, 110.48}

local function IntroCam()
   camera.CameraType = Enum.CameraType.Scriptable
   local rootPosition = Vector3.new(rps[CamNum], rps[CamNum + 1], rps[CamNum + 2])
   local cameraPosition = Vector3.new(cps[CamNum], cps[CamNum + 1], cps[CamNum + 2])
   camera.CFrame = CFrame.lookAt(cameraPosition, rootPosition)
end

BEvent.Event:Connect(function(num)
   CamNum = CamNum + 3
end)

RunService:BindToRenderStep("Cam", Enum.RenderPriority.Camera.Value + 1, IntroCam)

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