Hello! I’ve been having this problem lately, and I don’t really know how to fix this. My problem is that I’m making a replayer system, however the camera doesnt sync up with the character movements. The player’s camera’s cframe gets sent to the server and is stored through values, the camera and character updates every 0.075 seconds. However sometimes the camera is delayed, or ahead of the recording, how would I fix this?
-- client
local remote1 = script:WaitForChild("CameraCFrameEvent")
local RunService = game:GetService("RunService")
local timeElapsed = 0
RunService.RenderStepped:Connect(function(step)
timeElapsed += step
if timeElapsed >= 0.075 then
remote1:FireServer(workspace.CurrentCamera.CFrame, timeElapsed)
timeElapsed = 0
end
end)
I’ve also found myself in a similar problem when trying to develop an FPS game where you would be able to spectate a player through their first person view.
I found that the laggier the player is, the more inaccurate the camera is relative to the player position, and the less the camera gets updated.
For my case, I tried to add a compensation system, that tracks the players inputs and character velocity to then use that information as a way to somewhat predict where they are going to move inbetween the time the server needs to receive the client’s camera information.
I also tried lerping the character’s head cframe and the cam cframe.
At last I also used tween service to smooth it all out.
I don’t know how to fix your problem but I think you can use some of the solutions I tried to fix a similar problem I had. You could try sending the tick() in the FireServer() and utilize that somehow. It’s also important to note that I probably used a different system to get a client’s cframe because I had to send it to another client.
That’s what I found out too! I realized that I had a small little lag spike, and the camera got delayed as well! I’m glad I’m not the only one who’s having this problem! But about the tick(), I have NO idea how to use this, do you have any recommendations or tutorials?
tick() is basically a built-in function that returns a long number that basically says the time in seconds since some date in 2000/1999 You can use it to tell the server, when the camera update was sent, so I believe you can better organize the order in which the cframes appear in but this is something kinda complicated to me so I personally didn’t use this because of its complexity and because I was already happy with the result I acquired