CFrame offset issue

So I am making a module that attaches parts to the camera and I need to make an offset, the problem is

  1. the offset doesn’t work
  2. the offset does some weird artifacts like this (low quality)

Code :

obj.CFrame = cam.CFrame + cam.CFrame.LookVector * (ZOffset * (cam.FieldOfView / 70)) + Vector3.new(XOffset, YOffset, nil)
--This is the only line that is handling the part's position according to the camera
1 Like

In your current code XOffset and YOffset are not being applied relative to the camera CFrame, try this instead:

obj.CFrame = cam.CFrame * CFrame.new(XOffset, YOffset, -ZOffset * (cam.FieldOfView / 70))

if you want to keep part orientation constant:

obj.CFrame = CFrame.new(cam.CFrame * CFrame.new(XOffset, YOffset, -ZOffset * (cam.FieldOfView / 70)))
1 Like

okay now the offset thing works thank you !

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