Hello guys, I have an issue where my function for calculating aiming offset makes the locked into place, making it impossible for animations like firing to move the gun.
Does anyone have an idea how I could improve on the code to fix this issue?
local module = function(loadout, offset, scale)
local aimPartData = loadout.aim_part_data;
local aimPartCFrame = aimPartData.aim_part.CFrame;
local viewmodelCamCFrame = loadout.current.PrimaryPart.CFrame;
local aim_alpha = loadout.tween_values.aim_alpha.Value;
offset = CFrame.identity:Lerp(viewmodelCamCFrame:ToObjectSpace(aimPartCFrame), aim_alpha):Inverse();
return offset;
end;
return module;
Note: removing the Inverse() function at the end fixes the issue of animations not moving the gun, but of course the aiming offset is wrong in that case
What’s causing it is because the “aim part” is locked to the camera, so when the weapon moves, the camera moves with it, therefore making it look like the weapon isn’t moving. I’ve had this problem, I wasn’t able to fix it but I cheesed it.
I applied recoil to the camera using Springs which made it give the effect of the gun moving.
I am sorry if this advice doesn’t help too much but I hope it gives you a understanding of why this is happening. Have a good morning (at least for me)
I’m gonna look into the springs method since I always wanted to have some kind of dynamic visual recoil, thank you. Hopefully I figure out how to go around this eventually