Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How To Compensate for Gun Getting Closer To Camera?

Asked by
Pyracel 55
5 years ago

I am making a gun that will be used in first person. The arms are welded to the head which changes its angle based on the camera angle. It's working well except that depending on the angle, the weapon gets closer or farther from the camera. Is there a way to get around this?

Current Code

game:GetService("RunService").RenderStepped:Connect(function()  

    if Aiming == true then

        Mouse.TargetFilter = workspace 

        Player.Character.Torso.Neck.C1 = CFrame.new(0,-0.5,0) 

        Player.Character.Torso.Neck.C0 = CFrame.new(0, 1, 0) * CFrame.Angles(math.asin((Mouse.Hit.p - Mouse.Origin.p).unit.y), 0, 0)

    end

end)

Depiction of Problem: https://pasteboard.co/Hrh3ZEa.gif

0
When the hands are facinf down they are away from the camera.. but when they are facing upwards they are near the camera. I think. I think it may be something with the fact you welded the hands into your head. HeyItzDanniee 252 — 5y

Answer this question