'Watch' CameraType not working as expected

My goal is to make the camera move to a new part while still looking at the subject part and rotating to keep it in the center (using the Watch camera type). However, the camera does not rotate, but rather stays locked in place at the direction that the part is facing.

game.ReplicatedStorage.Events.Watch.OnClientEvent:Connect(function(subject,model)
	camera.CameraType = Enum.CameraType.Watch
	camera.CameraSubject = subject
	for i = 1,#model:GetChildren() do
		local part = model:FindFirstChild(i)
		if part then
			lockConnection = game:GetService("RunService").RenderStepped:Connect(function()
				camera.CFrame = CFrame.new(part.Position)
			end)
			wait(part:FindFirstChild("Time") and part.Time.Value or 6)
			lockConnection:Disconnect()
		end
	end
end)

subject is a single part while model is a model containing 1x1x1 parts that the camera moves to in order based on their names. It’s probably important to note that the subject does move.

I’ve tried not having the RenderStepped connection, however the camera will then move with the subject rather than just rotate to look at it, which is not the desired effect.

Edit: I figured out that it’s because the CFrame rotation is being reset, but I’m not sure how to keep it from being reset. I’m not the best with CFrame math.

3 Likes

That’s because

camera.CFrame = CFrame.new(part.Position) 

is just setting the position, while the rotation is being set to 0,0,0 constanly. Maybe do something like this

camera.CFrame = CFrame.new(part.Position)*CFrame.Angles(camera.CFrame:ToEulerAnglesXYZ())

camera.CFrame:ToEulerAnglesXYZ() is the rotation of the camera, we’re appending thing to the part’s position

I see. Will try it now, one moment

1 Like

Worked like a charm, thanks a lot!

1 Like