I want to add aiming on my gun. I put a part called AimPart on it and get the distance between the AimPart and the Camera and then give the viewmodel an offset based on the distance.
If I have my camera facing completely forward it works. But when I face another direction it doesn’t work.
https://streamable.com/1lp6nj
I have tried moving the viewmodel by its rightVector and upVector. And have tried flipping the camera position and the aimpart position in the subtraction.
if not Aiming then
local Dist = (Camera.CFrame.Position-Dummy.Client.AimPart.Position)
Offset=CFrame.new(Dist.X,Dist.Y,0)
Aiming=true
else
Offset=CFrame.new()
Aiming=false
end
Dummy.HumanoidRootPart.CFrame=((Camera.CFrame-Camera.CFrame.upVector*1.3)*CFrame.Angles(movementModel.x,movementModel.y,movementModel.z))*Offset
-- dummy is the viewmodel character.