I’m trying to figure out how to aim with my viewmodel
the issue is that i take the actual arms of the character and change the motor6d to the torso of the viewmodel, i have a AimPoint in my weapon and im trying to make the whole viewmodel move so the aimpoint is in the center of the screen but i cant really figure out how to do it
i looked at alot of devforms and none of them really seemed to help me
local offsetCF = CFrame.new(viewmodelOffset.X, viewmodelOffset.Y, -viewmodelOffset.Z)
local swayCF = CFrame.Angles(swayOffset.y, swayOffset.x, swayOffset.x/2)
local moveCF = movementCF
local finalCF = camCF * offsetCF * swayCF * moveCF
VM:SetPrimaryPartCFrame(finalCF)
rightShoulder.Part0 = VM.Torso
leftShoulder.Part0 = VM.Torso
leftShoulder.C1 = _C.defaultLeftArmC1
rightShoulder.C1 = _C.defaultRightArmC1
leftShoulder.C0 = _C.defaultLeftArmC0
rightShoulder.C0 = _C.defaultRightArmC0
This probably isn’t that helpful on its own but here is what you could do to make the viewmodel go to the aimPoint:
if aiming then
local finalAimingCFrame = (itemOffset:Inverse() * aimPoint.WorldCFrame:ToObjectSpace(viewmodel.PrimaryPart.CFrame));
if (aimingCFrame.Position - finalAimingCFrame.Position).Magnitude >= 0 then
aimingCFrame = aimingCFrame:Lerp(finalAimingCFrame, lerpingConstant)
end
else
aimingCFrame = aimingCFrame:Lerp(CFrame.new(0, 0, 0), lerpingConstant)
end
viewmodel.PrimaryPart.CFrame = camera.CFrame * aimingCFrame;
i tried piecing some of it together like the “ItemOffset” and it didn’t really help me, i also tried this method before you even gave it to me and i couldnt get it to work still either
local aimingCFrame = tool.Handle.AimPoint.CFrame
local finalAimingCFrame = (camCF:Inverse() * aimPoint.WorldCFrame:ToObjectSpace(VM.PrimaryPart.CFrame));
if (aimingCFrame.Position - finalAimingCFrame.Position).Magnitude >= 0 then
aimingCFrame = aimingCFrame:Lerp(finalAimingCFrame, 0.7)
end
VM.PrimaryPart.CFrame = camera.CFrame * aimingCFrame;