I have first person viewmodels and they work like a charm, but I’m not entirely sure how to make the offset of the viewmodel be changed to a position such as where the aimpart of the viewmodel is. I’ve tried using this code:
local aimPart = viewmodel:FindFirstChild("AIM")
if aimPart then
local aimPos = aimPart.CFrame:toObjectSpace(camera.CFrame)
local x, y, z = aimPos:toEulerAnglesXYZ()
adsOffset = CFrame.new(0, 0, 0.5) * CFrame.new(aimPos.X, aimPos.Y, aimPos.Z) * CFrame.Angles(x, y, z)
else
adsOffset = CFrame.new(0, 0, 0)
end
But the viewmodel always seems to appear from a very far distance away. As seen in this picture:
I have done some snooping around but never really found a solution to this problem. Could anyone help me here? I am getting annoyed by this very problem.
I’m not sure I understand your scenario exactly, but I think it’d be much simpler just to multiply the CFrame you have for your camera, to where you want it to be offset from the ads.
Typically for view models, you can have a reference point to be attached to the Camera’s CFrame (as mentioned above) - this is the easy way, provided that you handle such correctly. This, at the very least, covers the movement of the ViewModel. You already have this down, awesome.
For aiming, I would personally just use an animation with higher weighting but that may not be quite what you’re looking for. To me, it seems like you’re trying to get an offset for the viewmodel. A little more context or explicit details on what you’re looking for implementation-wise would be helpful to understand your problem better.
To respond to the above posts, what I basically mean is that the viewmodel should be positioned in an offset determined by the script by using an aim part. If you know of TurboFusion’s gun system, there is an “AimPart” which determines where the camera will be located at when aiming down sights. That is basically what I am trying to achieve here. I don’t want to manually set offsets for aiming down sights as that will be time consuming and using an aim part will be easier.