So for my first person shooter I made it so that the fake arms are suppose to move to a specific point when doing a motion which I set but its not working
Here are the variables I set
local moveOffset = CFrame.new(0.02, -0.014, -0.009) local lerpTime = .2
The code below is all done in renderstepped (I already did a print to check if moving is true and fakeArms are in the camera which do work as I already set their humanoidrootpart to the camera cframe but its torso is not moving.)
local startCFrame = fakeArms.Torso.CFrame if moving then fakeArms.Torso.CFrame:lerp(startCFrame * moveOffset, lerpTime) else fakeArms.Torso.CFrame:lerp(startCFrame, lerpTime) end
That did not work so I thought I'd need to keep adding the lerp time so I did it like this next.
local lerpTime = 0
Again the code below is all done in renderstepped
local startCFrame = fakeArms.Torso.CFrame if moving then if lerpTime < 1 then lerpTime = lerpTime + .2 end fakeArms.Torso.CFrame:lerp(startCFrame * moveOffset, lerpTime) else fakeArms.Torso.CFrame:lerp(startCFrame, lerpTime) end
If anyone knows the issue thanks for helping me in advance! :) ~KIHeros
There's a few complications here but I'll point out one I saw. This whole thing should make it move, but by the looks of things not how you want.
If you're not moving:
The CFrame will be set to a fraction of the fakeArms.Torso
's CFrame and startCFrame
, once. Which is presumably not what you expected. If you wanted it to reset to startCFrame
then you should have just set it. If you wanted it to tween back, you'd have to adjust lerpTime
If you're moving:
Those iterations aren't doing quite what you expect. It's not a lerp in the most normal sense, at the very least - The first iteration (0.2) is 0.2 of the way there. The second iteration is not 0.4 of the way there, and is fact 0.2+0.8*0.4
of the way there (uh-oh). The third follows this nasty recursive convention, as does the fourth, and the fifth is finally startCFrame*moveOffset