Pretty much what the topic name suggests.
I have a sprint animation that im trying to blend with a walking animation, but while transitioning limbs occasionally spasm in random directions for no apparent reason.
It’s really obvious when you spam sprint too.
The walk animation has core priority and was set to the walk animation in the default animate script, whilst the sprint animation is set to idle priority.
The portion of my movement script that controls the sprint weight is also below but I don’t think it has any issues.
Any insights from anyone? Or is roblox just in desperate need of updating animations?
btw I have my own animation loader which is why the methods for AdjustSpeed()
and AdjustWeight()
are actually SetSpeed()
and SetWeight()
function lerp(a, b, t)
return a + (b - a) * t
end
function MovementTick(dt: number) -- OnRenderStepped
if not HumanoidRootPart then
return
end
if not Humanoid then
return
end
local MoveDirection = Humanoid.MoveDirection
local FloorMaterial = Humanoid.FloorMaterial
local Acceleration = PlayerStats:GetStat("Acceleration")*.3
local CanSprint = PlayerStats:GetState("CanSprint")
if MoveDirection.Magnitude > .1 and FloorMaterial ~= Enum.Material.Air then
WalkingAcceleration = math.clamp(lerp(WalkingAcceleration, 1-SprintingAcceleration, 1/Acceleration * dt), 0.01, 1)
else
WalkingAcceleration = math.clamp(lerp(WalkingAcceleration, 0, (1/Acceleration) * dt)-SprintingAcceleration, 0.01, 1)
end
if IsSprinting and MoveDirection.Magnitude > .1 and FloorMaterial ~= Enum.Material.Air and CanSprint then
SprintingAcceleration = math.clamp(lerp(SprintingAcceleration, 1, 1/Acceleration * dt), 0.01, 1)
else
SprintingAcceleration = math.clamp(lerp(SprintingAcceleration, 0, (1/Acceleration) * dt), 0.01, 1)
end
local Velocity = HumanoidRootPart.AssemblyLinearVelocity
local Walkspeed = PlayerStats:GetStat("Speed")
local SprintSpeed = PlayerStats:GetStat("SprintSpeed")
FootstepObj:SetSpeed((MoveDirection.Magnitude - SprintingAcceleration) + (SprintingAcceleration * 1.2))
Humanoid.WalkSpeed = Walkspeed + (SprintSpeed * SprintingAcceleration)
if SprintAnim.AnimationTrack.IsPlaying then
print(`Sprint Anim Weight: {SprintingAcceleration}`)
SprintAnim:SetWeight(SprintingAcceleration)
end
end
local SprintBegan = BasicBind:ListenToInputBegan(PlayerKeybinds:GetBind("Sprint")):Connect(function ()
IsSprinting = true
end)
local SprintEnded = BasicBind:ListenToInputEnded(PlayerKeybinds:GetBind("Sprint")):Connect(function ()
IsSprinting = false
end)
function OnRun(PlayerSpeed: number) --On Humanoid.Running
local Walkspeed = PlayerStats:GetStat("Speed")
local SprintSpeed = PlayerStats:GetStat("SprintSpeed")
if PlayerSpeed > 0.01 then
local SprintAnimSpeed = (PlayerSpeed/(Walkspeed+SprintSpeed)) - .2
if not SprintAnim.AnimationTrack.IsPlaying then
SprintAnim:Play(.2, SprintingAcceleration, SprintAnimSpeed)
return
end
SprintAnim:SetSpeed(SprintAnimSpeed)
return
end
SprintAnim:Stop(.1)
end