Tweening CFrame.lookat()

Trying to make a camera transition type thing, what I really want is the camera angle to change when I leave a room. Here’s what I mean:

To clear up some confusion, I don’t want a camera transition to go through the door first, rather I want it to smoothly transition into an isometric angle, quite buggy isn’t it?

I’m not even sure if I should be using tweens for this. And if not, how should I go about it?

local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local cam = workspace.CurrentCamera

local cam_depth = 64
local height_offset = 2

local houseDetection = workspace:WaitForChild("HouseDetection")
local house = true

cam.FieldOfView = 25

RS.RenderStepped:Connect(function(deltaTime)		
	local character = player.Character
	
	houseDetection.Touched:Connect(function()
		house = true
	end)
	
	houseDetection.TouchEnded:Connect(function()
		house = false
	end)
	
	if character then
		local hrp = character:FindFirstChild("HumanoidRootPart")
		if hrp then
			if house then
				local cam_pos = workspace.HouseCamTest.Position
				
				TS:Create(cam, TweenInfo.new(.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false), {CFrame = CFrame.lookAt(cam_pos, hrp.Position)}):Play()
			else
				local hrp_pos = hrp.Position + Vector3.new(0, height_offset, 0)
				local cam_pos = hrp_pos + Vector3.new(cam_depth, cam_depth, cam_depth)
				cam.CFrame = CFrame.lookAt(cam_pos, hrp_pos)
			end
		end
	end
end)
3 Likes