Issue with viewmodel ADS offset

Hello, I’m having an issue with my viewmodel system.

Whenever I aim, it’s offset off the actual sight for some reason, but when I use a plugin to lock my camera onto the AimPart it’s perfectly centered.

screenshot in-animation with the camera plugin

screenshot of in-game aiming

*code for calculating aim offset

aimOffset = aiming and currentViewmodel.AimPart.CFrame:Inverse() * currentViewmodel.FakeCamera.CFrame or CFrame.new()

Any and all help is appreciated!

It appears that it was not centered in the animation, if anyone could help me with it automatically centering while aiming it would be appreciated.

rather than using a fake camera part, just calculate the cframe yourself, just get the center of the model and add an offset that you can adjust for every gun

I’ve thought about this, however I was wondering how I’d be able to do it automatically.

If you mean getting the offset then:

get the offset from the fake camera part to a set part on the tool (only once)
and then multiply that offset by the part’s position every time you update the vm’s position

I already get the offset, it’s just that when animations rotate the gun the offset ignores it.

So do what i told you and get the offset only once and calculate the new offset before updating the vm’s position

-- when first equipped
local offset = tool.Handle.CFrame:Inverse() * fakeCamera.CFrame
[...]
-- when updating the aim offset
aimOffset = aiming and currentViewmodel.AimPart.CFrame:Inverse() * (tool.Handle.CFrame * offset) or CFrame.new()

This doesn’t work, I’ve tried it and it doesn’t change the viewmodel’s CFrame at all when aiming.