I’m working on the framework for a little somethin’ and im making a crosshair point at where the gun will shoot. However, it’s weirdly offset even though everything is properly set with the .5 Anchorpoints and yadda yadda.
I figured out its because the camera gets offset by (2.75, 0.25, 0) every time you aim. I thought the function would go with this since, the camera is moved. but i thought wrong.
i’ve tried various things, mainly with subtracting the offset and all have either had horrible results or had close results but unfavorable at distances.
--Binded to renderstepped
local m:Model = character:FindFirstChild(charVar.tool.Name .. "WorldModel")
local fp:Attachment = m:WaitForChild("Barrel"):WaitForChild("FirePoint")
local result = workspace:Raycast(fp.WorldPosition,fp.WorldCFrame.LookVector*5000,param)
if result then
if gunCurs then
gunCurs.Visible = true
local vect,onscreen = game.Workspace.CurrentCamera:WorldToViewportPoint(result.Position)
local depth = vect.Z
gunCurs.Position = UDim2.fromOffset(vect.X ,vect.Y)
gunCurs.Position = UDim2.new(gunCurs.Position.X.Offset/gunCurs.Parent.AbsoluteSize.X,0,gunCurs.Position.Y.Offset/gunCurs.Parent.AbsoluteSize.Y,0)
gunCurs:FindFirstChildWhichIsA("UIScale").Scale = 1 + depth/100
end
end