RoPID controller

Demo: Видео 10-07-2022 01:14:11.mp4
Hi everyone! i using RoPID for smooth camera movement,
The problem is that the camera jerks at speed, as if it is lagging behind and catching up with jerks. How can this be fixed?

local RunService = game:GetService("RunService")
local RoPID = require(script.RoPID)
local Vec3 = require(RoPID.Util.Vec3)

local controller = Vec3.new(0, 2, 0)
local camera = game.Workspace.CurrentCamera
local goal = game.Workspace:WaitForChild("C100").Chassis.CameraPoint
wait(15)
local function rr(dt)
	local output = controller:Calculate(goal.Position, camera.CFrame.Position, dt)
	camera.CFrame = CFrame.new(output) * CFrame.fromOrientation(math.rad(goal.Orientation.X),math.rad(goal.Orientation.Y),math.rad(goal.Orientation.Z))
	camera.CameraType = Enum.CameraType.Scriptable
end

RunService:BindToRenderStep("RunCam", 0, rr)

What exactly do you mean by “jerk”? Do you just need to tune your pid values? Or maybe increase your render priority?

Here you can see the problem better - Video
When the bus starts to move, the camera starts to lag. I tried to set different render priorities ( 0 - 10 ), it doesn’t help.

1 Like

The correct render priority would be Enum.RenderPriority.Camera.Value + 1, so use that.

This just looks like replication lag to me though. Have you set the network owner of the bus to the person driving? See if that does anything.

I set this priority, did not help
When a person gets on the bus, he becomes the owner of the bus and the network through the script. If you turn off this camera script and set the default camera, then the bus rides smoothly Video, there are no lags. Therefore, the problem is most likely in the installation of the CFrame camera

Just FYI to simplify things while I look for issues you can do this:

camera.CFrame = goal.CFrame.Rotation + output

Also if you just set the camera CFrame to a static offset without the PID do you still get jerks? E.g

camera.CFrame = goal.CFrame * CFrame.new(0, 0, 15)

without PID there are no lags, everything is smooth

BusGame.rbxl (1.1 MB)
Maybe that will make it easier to understand what the problem is?
The camera script is in StarterPlayerScripts

The problem is still relevant…

Try setting Camera.CameraType outside of the RR function.

tried it but it didn’t help…:slight_smile:

Is the issue in your code or in the PID thing. I never used PID, so I may not be able to help you

Topic up. The problem is still relevant

You only tuned your integral gain so you dont even have a stable pid controller.not sure why the behavior is still tolerable, probably dumb luck tbh. if your whole thing is it isnt smooth I would just interpolate it. You only use PID for stuff that has no equation