Camera being snapped back after tween completion

I have a custom 3rd person camera, and I wanna be able to do animations with it, so I unbind my camera so I can then do tweens. But once said tween has finish, it justs gets reset back to the position it was before hand?
ezgif.com-gif-maker (59)

local function GetDefaultPosition()
	local Character = Player.Character
	if not Character then return end
	
	local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
	if not HumanoidRootPart then return end
	
	local PlayerPosition = HumanoidRootPart.Position
	local CameraPosition = PlayerPosition + OFFSET
	
	return PlayerPosition, CameraPosition
end

--// Update camera movement
local function UpdateCamera()	
	-- Get default position
	local PlayerPosition, CameraPosition = GetDefaultPosition()
	if not PlayerPosition or not CameraPosition then return end
	
	CurrentCamera.CFrame = CFrame.new(CameraPosition, PlayerPosition)
end

function CameraController:Dialogue(npcCFrame)
	RunService:UnbindFromRenderStep("Camera")
	
	local Tween = TweenService:Create(
		CurrentCamera,
		TweenInfo.new(0.5),
		{
			CFrame = npcCFrame * CFrame.Angles(math.rad(20), math.rad(180), 0) + Vector3.new(-8, 2, 0)
		}
	)
	Tween:Play()
end

function CameraController:Start()	
	CurrentCamera.FieldOfView = FOV
	
	-- Bind camera
	RunService:BindToRenderStep(
		"Camera",
		Enum.RenderPriority.Camera.Value,
		UpdateCamera
	)
end

I’ve put prints inside the UpdateCamera function, as soon as the :Dialogue is called, it stops, so the unbinding is working. Just unsure why after my tween it reverts back to its original position

do you set the cameratype to scriptable

1 Like

Have you tried reversing the camera tween?

Ye, sorry was at the top, forgot to include, but I do

CurrentCamera.CameraType = Enum.CameraType.Scriptable

I don’t want it to reverse, it should stay as is when tween finishes

have you tried manually setting the camera CFrame to the desired position after the tween has finished

Appears that the “Camera” RenderStep binding is on its own journey even after unbinding it here… Not sure why that’s happening. Maybe the “Camera” is already used or something in the game Engine or something? Looks like one of those crazy occurrences that seems to come from nowhere to me :smiley:
I would recommend changing the name to something wild or using a variable that represents a string of that binding.

Just tried it, still ended with same result :confused:

--// Tween camera to character
function CameraController:Dialogue(npcCFrame)
	RunService:UnbindFromRenderStep("Camera")
	
	local Goal = npcCFrame * CFrame.Angles(math.rad(20), math.rad(180), 0) + Vector3.new(-8, 2, 0)
	
	local Tween = TweenService:Create(
		CurrentCamera,
		TweenInfo.new(0.5),
		{
			CFrame = Goal
		}
	)
	Tween:Play()
	
	coroutine.wrap(function()
		Tween.Completed:Wait()
		
		CurrentCamera.CFrame = Goal
	end)()
end

are you sure the cameratype is actually changed? I’ve had instances where the cameratype isn’t changed for some reason when I change the cameratype near the top of a localscript

Huh yeah that seemed to be the issue :confused:

Nearly 2 years later this saved me after hours of a headache. There’s a special place in heaven for you