Hello so I am working on a new FPS style game and I am working on Iron sights. I wanted the gun to have an animation in between the Hip fire and when aiming down the sight. So I used a CFrame Lerp for this. The issue is it seems like it skips the animation completely like this:
Here is the code for the Function that controls the Animation. Everything else in the code should be fine, it is just the animation that needs fixing:
function AimAnim()
if model ~= nil then
if aiming == true then
local CFrame1 = cam.CFrame * CFrame.new(model.CFrameSet.Value)
local CFrame2 = cam.CFrame * CFrame.new(model.AimCFrameSet.Value)
for i = 0, .2, 1/60 do
model.PrimaryPart.CFrame = CFrame1:lerp(CFrame2,i)
wait()
end
aiminganim = false
else
local CFrame2 = cam.CFrame * CFrame.new(model.CFrameSet.Value)
local CFrame1 = cam.CFrame * CFrame.new(model.AimCFrameSet.Value)
for i = 0, .2, 1/60 do
model.PrimaryPart.CFrame = CFrame1:lerp(CFrame2,i)
wait()
end
aiminganim = false
end
end
end
Ok, so I gave it a try. Nothing much has changed. However it did increase the time it takes to start aim down sights. There is still no animation in between it. Thanks for the suggestion though!
try using TweenService to tween the parts. Unanchor all the parts except for the part that is tweened, and put weld constraints in the tweened part to connect all of the other parts.
And lastly, tween the tweened part and the model should be tweened alongside it.
If you don’t understand what I mean, maybe try looking at this topic.
Thanks for suggesting the TweenService for parts now the animation is super smooth. There are a few things I need to tweak like when you want to aim down while moving but this is a great leap in the right direction. Thank you so much: