So I have a simple sine animation I’m using for my viewmodel’s arm. Basically, it moves when your character begins to walk.
I realized though, it looks odd how the sine animation offset does not reset when you stop moving, the animation just merely stops running, but the arm remains in the same place.
I wanted to implement a thing where once you stop moving, the animation seamlessly transitions back to the default position.
The problem I’m running into though, is when the character starts walking again, the arm might stutter to a different position each time, due to the sine values being very far off from the default position when I lerp it back to a blank identity CFrame. (if that makes any sense at all, basically it isn’t a smooth transition from the default position anymore.)
I can try to clarify further if needed. Thanks for any advice
--//Make sure viewmodel is active
if not viewmodel.Parent then return end
if isCharacterWalking() then --//Handle sway animations for the viewmodel
local sineMultiplier = (sprintActive(characterModel) and 1.5) or 1
XSway += X_SINE_INCREMENT * sineMultiplier * dt
YSway += Y_SINE_INCREMENT * sineMultiplier * dt
swayCF = swayCF:Lerp(CFrame.new(0, math.sin(YSway)*.04, math.sin(XSway)*.02), .5+dt)
else
-- //Animate arm back to its default position
swayCF = swayCF:Lerp(CFrame.new(), .5+dt)