Camera not foucsing correctly

My issue is that the camera is not focusing on the part, Mesh below

problem fixed

My issue is that the camera is not focusing on the part, Mesh below

You’re setting the camera’s CFrame to be the mesh’s CFrame, then a random offset, then the part’s CFrame, then your desired angle.
This is incorrect because the CFrame of the mesh has the x, y and z coordinates of the mesh, but the CFrame of the part will contain the x, y and z coordinates of the part. Setting the camera’s CFrame to the mesh’s CFrame then the part’s CFrame will cause the camera to move to a position as if it were between the mesh and the part, which is probably not what you want.
Try something like this instead:
local camMovewithMouse = function()
if during == true then
local maxTilt = 15
wait(.5)
Camera.CFrame = Mesh.CFrame + (Mesh.CFrame.LookVector * -1) * camPart.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end
end

What this code does is it sets the camera’s CFrame to be the mesh’s CFrame, then the inverse of the LookVector of the mesh’s CFrame, then the part’s CFrame, then your desired angle. This should move the camera to be behind the mesh and then point towards it.

It works thank you for your support!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.