I recently started a custom camera script and encountered camera tweening. My goal was to have the camera follow a part at a certain distance and of course as smoothly as possible, but my script behaved very strange, the camera moved very quickly from the sky to the part and that happens every time the Part moves. The script behaves perfectly if I don't add an offset to the camera.

Not working (Strange camera movement)

local tween = TweenService:Create(camera,TweenInfo.new(.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),{CFrame = CFrame.new(target.Position) + Vector3.new(0,100,100), Focus = CFrame.new(target.Position)})
tween:Play()

Working (No camera offset)

local tween = TweenService:Create(camera,TweenInfo.new(.1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),{CFrame = CFrame.new(target.Position), Focus = CFrame.new(target.Position)})
tween:Play()

Edit

After a few tests I found that the strange behavior disappears when I add the offset to the focus. Why is that? And is there any way to fix this since I want to use focus without offset?

3 comments

0

It might be because you are constantly updating the Tween, and it isn't finished when you start a new Tween

0

Shouldn't the strange behavior also occur if I don't add an offset then?

0

Okay, I tested it, it can't be the timing, I added a debounce that only allowed the tween to run once a second and the tween finishes in .1 seconds but the problem persists