Hi, I am working on my viewmodel framework and I have a basic grip on it but I ran into a problem.
I want to know how to make my viewmodel animations switch smoothly. For example, if I were to change from a walking state to a running state, it would smoothly change to a running state.
https://gyazo.com/e06d2a20afaaf463426149ce3fcb0cf8
Here’s my code
function vhandler:Update(DT)
if self.viewmodel then
local rotation = self.camera.CFrame:ToObjectSpace(self.lastCameraCF)
local x,y,z = rotation:ToOrientation()
self.swayCF = self.swayCF:Lerp(CFrame.Angles(math.sin(x) * self.swayAMT, math.sin(y) * self.swayAMT,0),0.1)
self.lastCameraCF = self.camera.CFrame
self.viewmodel:SetPrimaryPartCFrame(self.camera.CFrame * self.swayCF)
if self.character:FindFirstChild("Humanoid") then
local humanoid = self.character:FindFirstChild("Humanoid")
--local MoveVector = Controls:GetMoveVector()
--MoveVector = Vector3.new(
-- ThumbstickCurve(MoveVector.X),
-- ThumbstickCurve(MoveVector.Y),
-- ThumbstickCurve(MoveVector.Z)
--)
--print(MoveVector)
local speed = humanoid.WalkSpeed
if speed >= 3 and speed < 11 then -- walking
print("walking: "..speed)
end
if speed >= 12 then
print("sprinting: "..speed)
end
end
end
end
This function connects to a renderstep in a local script