Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Scriptable camera stutter with a plane, how can I mitigate this?

Asked by 6 years ago
Edited 6 years ago

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

1
This may not necessarily be a problem yet but I would advise you actually to learn networkownership and set the plane to client controlled, if someone has excessive network lag my guess is that your plane is going to be very very bumpy to them in the current system Vulkarin 581 — 6y
1
It doesn't look like it's your camera. If you look at the skybox, those elements don't stutter. It looks like it might be your ship movement script instead. Post that. Also, your camera movement script does not utilize the delta time to compensate for variances in time, which will also be a source of stutter. Cousin_Potato 129 — 6y
0
@Cousin_Potato, if you really think it's the movement script I can post that, but I would be confused to why that would cause the stutter. The plane does not stutter until the camera script actually starts which would imply that it is indeed the camera script? Maybe I'm completely wrong about that though, which is very possible in all honesty. pieguy100000 28 — 6y
1
Also, @Vulkarin, I agree I should learn more about network ownership. I just have a hard time grasping how it really works and what it affects in game. pieguy100000 28 — 6y
View all comments (3 more)
1
Your camera priority matters. If you're moving the ship to the previous camera position, that will cause it to stutter. Use BindToRenderStep in your movement script instead and set the priority to after the camera has been moved. Like I said, your movement script should also take into account the inconsistent time between frames otherwise the ship will move a different amount each frame. Cousin_Potato 129 — 6y
0
Okay I see what you're saying now. This is pointing me in the right direction. Thank you! pieguy100000 28 — 6y
1
I've gone through a similar issue before. Unfortunately, I've buried the code somewhere, no idea, but this link might also be useful. https://devforum.roblox.com/t/fixing-jittery-cframe-lerping/162629 Cousin_Potato 129 — 6y

1 answer

Log in to vote
1
Answered by
oilsauce 196
6 years ago
Edited 6 years ago

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.

0
Thank you for your response! I think I am beginning to understand what you explained there. I did try Lerping at one point, but it didn't really seem to fix the issue and it seemed to remove some functionality of the camera, so I decided to go back to interpolation. Using interpolation also allowed the camera to roll with the plane, but lerping did not. I will post a GIF to show you what I mean. pieguy100000 28 — 6y
Ad

Answer this question