The only part in my viewmodel that is moved is the gun’s handle, the rest of the gun is welded to the handle, and the hands use inverse kinematics for the holding and reloading animations.
Because of this when I lerp the gun for example for aiming and reloading, the gun lags behind, presumably because it’s also lerping the position (which is always kept relative to the viewmodel’s HRP unless aiming).
In the video below, you can see how bad this looks when I spam the aim button, or reload even, as it lags behind a noticeable amount, this is also an issue with reloading and because of this I’ve had to keep the time increase of the lerp alpha to pretty smal numbers so it’s not so noticeable, but this looks bad as it makes gun movements very snappy.
I’ve tried to fix this by separating the viewmodel’s CFrame from the target CFrame for the gun’s handle and multiplying the viewmodel’s cframe by the lerp before setting it to the handle’s CFrame, which only causes the viewmodel to freak out if the lerp alpha is less than 1.
How I set the viewmodel’s CFrame:
vm_hrp.CFrame = cam.CFrame * vmOffset.Value
The code that sets the target Cframe:
gunTargetCFM = (
not aiming and vm_hrp.CFrame * gunOffset * fireRecoilHip * springPositionalOffset * springAngularOffset or
gunHandle.CFrame * getAimOffset() *recoilPositionalOffset*fireRecoilAiming * sineOffset * swayAimOffset * springADS()
)
The code that lerps the aim transition:
gunHandle.CFrame = gunHandle.CFrame:Lerp(gunTargetCFM,(aimTime < 1 and aimTime or 1))
-- same as reload transition:
gunHandle.CFrame = gunHandle.CFrame:Lerp(gunTargetCFM,reloadAlpha.Value/100)
I’m honestly not sure how to do this as I know it has to do with the gun’s position lagging behind because the part that keeps it relative is being lerped, however I do need to change the gun’s position and rotation when aiming or reloading while keeping it relative, and my attempts to fix it have only made it worse.
What happens when I add the viewmodel’s cframe to the target lerped cframe :
What this looks like:
(targetCFM is the same as gunTargetCFM)
targetCFM = gunHandle.CFrame:Lerp(gunTargetCFM,(aimTime < 1 and aimTime or 1))
gunHandle.CFrame = not aiming and vm_hrp.CFrame * targetCFM or targetCFM
As you can see, any gun movement when I separate the viewmodel CFrame from the lerp CFrame makes the gun disappear(??), I’ve looked all over devforum for a fix for over a week now, and experimented a few different ways myself but never found anything that actually worked.