How to make your crosshair stay in the center while the camera is moving?

This is what I wanted


I’ve been searching some topics about this problem still cant understand how

Here is my idea, never tested it out I would like you try it out.

Offset the camera using this variable in order to retain the original camera:

Using the original camera CFrame get the crosshair position in front of the camera using look vector.

--Gets the world position 1 stud ahead of the original camera before shake
local crosshairWorldPosition = originalCameraCF.Position +originalCameraCF.LookVector

Convert it back to 2d position using world to screen point.

local vector, onScreen = camera:WorldToScreenPoint(worldPoint)

Place the GUI at that 2d position.

What do you mean by offsetting my camera?, besides my camera is bugged if i input that

found the solution

if Fake:FindFirstChild(“FakeCamera”) then
if (Camera.Focus.p-Camera.CoordinateFrame.p).magnitude <= 1 then
if CFAngles then
local v = WorldToScreen((Camera.CFrame * CFAngles:Inverse() * CFrame.new(0, 0, -4)).Position)
local v2 = Camera.ViewportSize / 2
GUI.Crosshair.Position = (v - v2).Magnitude > 0.08 and UDim2.new(0, v.X, 0, v.Y - 36) or UDim2.new(0, v2.X, 0, v2.Y - 36)
else
GUI.Crosshair.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end
else
GUI.Crosshair.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end
else
GUI.Crosshair.Position = UDim2.new(0, Mouse.X, 0, Mouse.Y)
end

the fake variable is my camera part of the viewmodel

1 Like

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