Camera's Cframe makes "popping" when the Look Vector target surpasses certain height

This is the code:

--Camera logic
function OnRenderStep(deltaTime)
	
	--Update continously the camera for the required usages	
	if currentCameraUsage == "AnchoredDance" then
		camera.CFrame = CFrame.new(trackingPart.Position, characterClone.Head.Position)
	end
	
	wait(deltaTime)
end

--When a frame renders, use the camera logic
RunService.RenderStepped:Connect(OnRenderStep)

Here is a video describing the issue better:

As you can see, when the character reaches some height, the camera moves abruptly for a moment.
I don’t know how to actually fix that. Any help would be appreciated :slight_smile:

1 Like

–On character move, update camera
function OnCharacterMove(input)

–If the character is on the ground and is not moving, change camera
if characterClone:FindFirstChild(“HumanoidRootPart”) and characterClone.HumanoidRootPart.Velocity.magnitude <= 1 then
if currentCameraUsage == “Follow” then

–Make a clone of the character’s head
trackingPart = characterClone.Head:Clone()

–Anchor it to the character
trackingPart.CFrame = CFrame.new(trackingPart.Position, characterClone.Head.Position)
trackingPart.Parent = characterClone

–Update current camera usage
currentCameraUsage = “AnchoredDance”

end
else
if currentCameraUsage == “AnchoredDance” then
trackingPart:Destroy()
currentCameraUsage = “Follow”
end
end

–If the camera is following the character, update the camera
if currentCameraUsage == “Follow” then
camera.CFrame = CFrame.new(characterClone.Head.Position - 1.5 * characterClone.Head.CFrame.lookVector, characterClone.Head.Position)
end

end

–On character move, use camera logic
game:GetService(“UserInputService”).InputBegan:Connect(OnCharacterMove)

–On camera move, update the clone
function OnCameraMove(input)

–If the camera is not following the character, update the ccloned character
if currentCameraUsage ~= “Follow” then
characterClone.Head.CFrame = camera.CFrame
end

end

–On camera move, use camera logic
game:GetService(“UserInputService”).InputBegan:Connect(OnCameraMove)

1 Like

Excuse me, that answer assumes things that I don’t even contemplate.
Did you generate that using GPT3? That’s not valid sorry.

I’m only having problems with the CFrame I think. That answer lacks context…

1 Like

You can fix it by setting the camera’s Cframe with the Lerp function. Here is an example:

 
 --Update continously the camera for the required usages
 if currentCameraUsage == "AnchoredDance" then
  --The camera lerps to the char head position
  camera.CFrame = camera.CFrame:Lerp(CFrame.new(trackingPart.Position, characterClone.Head.Position), deltaTime * 4)
 end
 
 wait(deltaTime)
end

--When a frame renders, use the camera logic
RunService.RenderStepped:Connect(OnRenderStep)
1 Like

AIl would have to guess that since you arent using the camera mode of scriptable when the camera changes cframes, the default one it might be on could have limitations on how much pitch it can go, thus making some weird snapping movement when it has too much pitch. You could try changing the camera mode to scriptable if its playing that little cutscene i would guess. Im on phone atm so I cannot test this rn

1 Like

The weird thing is that it’s already set to scriptable. I’m going to try finding if there is any camera limitations.

1 Like

Okey, I managed to fix it, using the lookAt function.

camera.CFrame = CFrame.lookAt(trackingPart.Position, characterClone.Head.Position)

oh awesome, roblox camera be on a weird level fr

2 Likes

Yup, I think Unity’s cameras are simpler to manage.

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