Rover Camera not working/stable

I’ve encountered an issue with the rover’s camera. The camera isn’t behaving as expected; instead of smoothly following the rover or providing a dynamic view, it remains fixed in one position. This lack of stability prevents it from adapting to the rover’s movements or changing perspective, which affects the overall gameplay experience. How can I fix this issue so that the camera functions correctly and follows the rover as intended?

Here is the video & picture:

Here is the video

Server:

local rs = game:GetService("ReplicatedStorage")
local remotes = rs.Remotes
local remote = remotes:WaitForChild("RemoteEvent")

local part = workspace["Rover One"].CameraB.BaseCamera

local currentMousePos

remote.OnServerEvent:Connect(function(player, mousePos)
	currentMousePos = mousePos
end)

while task.wait() do
	if part and currentMousePos then
		local partPos = part.Position

		local screenPoint = workspace.CurrentCamera:ScreenPointToRay(currentMousePos.X, currentMousePos.Y)
		local direction = screenPoint.Direction
		local distance = (partPos - screenPoint.Origin).magnitude

		local targetPosition = screenPoint.Origin + direction * distance

		local targetCFrame = CFrame.lookAt(partPos, targetPosition)

		local currentCFrame = part.CFrame
		part.CFrame = currentCFrame:Lerp(targetCFrame, 0.1)
	end
end

Client:

local player = game.Players.LocalPlayer
local getMouse = player:GetMouse()

local rs = game:GetService("ReplicatedStorage")
local remotes = rs.Remotes
local remote = remotes:WaitForChild("RemoteEvent")

getMouse.Move:Connect(function()
	local mousePos = getMouse.Hit.Position
	remote:FireServer(mousePos)
end)

I searched on YouTube but couldn’t find a solution. I’m hoping this developer hub can help me resolve the issue.

2 Likes

The problem is that it is being updated using the Server Position property and not the client in which it has network ownership. (Server lags behind client)

Visualization:

Better to use hinge constraints if going for a complete physics based solutions, or welds for pure CFrames.

Or perhaps you can use .Stepped:Wait() to let the vehicle turret position update first?

Try not mix the 2 for this specific scenario.

I think your camera has collisions on and that’s why it’s glitchy. And the reason it’s not following the rover, @dthecoolest has already explained.

The camera collision is already turned off.

I rewatched the video and I don’t think it’s what the other guy said. The camera isn’t lagging behind, something is wrong with the way you’re calculating the CFrame

You’re using CFrame:Lerp() but you’re always setting the alpha (2nd argument) to 0.1, I think that’s why it’s not positioned correctly. Try setting it to 1 and see what happens.

It’s still the same on my end. I’m not a very experienced programmer, so I’m not sure how to fix it.

Is your BaseCamera part welded to the Rover?

No, It’s not welded to the Rover.

So when you move the Rover the BaseCamera part stays in the same position and doesn’t move with the rest of the Rover. You have to weld them together.

Welding it doesn’t allow the camera to move with the mouse pointer. I’ve already tried it. Additionally, it causes the rest of the rover, including the camera, to fling out.

I’m confused, can you send a screenshot of the BaseCamera


Here is the screenshot of the BaseCamera that you wanted.

I’m also confused. I have no idea.

Okay so the reason the position isn’t changing is because you’re setting it to the same position. You need a part that’s moving with the Rover, you can copy the BaseCamera make it invisible and weld it to the Rover, then set the BaseCamera to the welded parts position.

The Rover looks like it’s anchored: Video

Sorry, I typed to one to another. Are you still confused?

I don’t have access to the video

I recommend just using hinge constraints if you are a beginner. This should work:

Sorry, I fixed the permissions problem.