I’m trying to make custom animation script, But I got some problem that when I stop walking, transition cracks and it’s connection looks really bad.
https://gyazo.com/eff3cb3f80a8c55de5a9b0db2ccd2b6b
I think when transition starts, transition starts from animation’s start, not current time position.
local status = "idle"
local motionPlaying = nil
-- Cancel old motion
local function stopMotion(transition)
if transition == nil then
transition = 0
end
if motionPlaying ~= nil then
motionPlaying:Stop(transition)
end
end
-- Cancel old motion and play new motion
local function playMotion(motion, transition)
stopMotion(transition)
motionPlaying = motion
if transition == nil then
transition = 0
end
motion:Play(transition)
end
-- Get player speed
humanoid.Running:Connect(function(speed)
if speed > 0.01 then
local selectedMotion = nil
local adjust = 1
if humanoid:GetAttribute("sprint") == false then
selectedMotion = motions[selectedPack].movement.walk
else
selectedMotion = motions[selectedPack].movement.run
end
status = "run"
playMotion(selectedMotion, 0.1)
motionPlaying:AdjustSpeed(getCurrentSpeed() / settingData.walkSpeed)
else
status = "idle"
playMovement(1)
end
end)