Hi all,
I've been dealing with this particular issue for a while now. Here is a GIF that demonstrates the issue. You will notice that there is no stutter for the first few seconds, as the camera script hasn't activated yet.
I was reading this post from the DevForum as it seems like it was a similar issue to mine, but I could not get anything useful out of it. Setting network ownership seemed to just freeze the plane where was.
Here is my camera code:
local Camera = workspace.CurrentCamera wait(20) game:GetService("RunService").RenderStepped:connect(function() Camera.CameraType = Enum.CameraType.Scriptable Camera.CameraSubject = workspace.plane.Front Camera:Interpolate(workspace.plane.Front.CFrame* CFrame.new(0, 10, 50),workspace.plane.Front.CFrame,.5) end)
Any tips or advise or anything really would be appreciated!
EDIT:
Interpolation and camera roll: GIF
Lerping and no camera roll: GIF
There is nothing particularly wrong with the code, it's just inconvenient.
Camera:Interopolate tweens the Camera in a linear fashion towards a new Camera.CFrame and Camera.Focus over a given duration. If you fire it once, it'll go all the way from point A to point B. But since you're doing this at a rate of 1/60th of a second, there are multiple tweens running at the same time and they all have a different goal to tween to since the point B is constantly changing.
We have another method for this, Lerping. (:lerp()
)
This stands for Linar Interopolation, and is similar to Camera:Interopolate, but it doesn't go from point A to point B when you fire it once.
It returns the position of the caculated distance between point A and point B by the desired step. (In your case, 0.5.)
local Camera = workspace.CurrentCamera wait(20) game:GetService("RunService").RenderStepped:connect(function() Camera.CameraType = Enum.CameraType.Scriptable Camera.CameraSubject = workspace.plane.Front Camera.CoordinateFrame = Camera.CoordinateFrame:lerp(CFrame.new(workspace.plane.Front.CFrame* CFrame.new(0, 10, 50).p ,workspace.plane.Front.CFrame.p), .5) end)
If you run :lerp() rapidly, it probably won't stutter anymore because unlike tweening, it won't go from point A to the previous point B, but instead it will go from point A to wherever the point B is at, when it's fired.
You might've not understood some of the stuff I said, I'm really not the best at explaining. If you have any questions, you're free to ask and I'll try to answer it as easily as possible.
Thanks for reading, I hope I helped.