Hey! So, for the record, I’m working on a directional walking system, and the one I have right now works just fine, but there are some problems while walking diagonally with the animations. Sometimes the animations overlap, and that’s exactly what I wanted because it’d look like the legs are walking diagonally, problem is, this bugs out at times and if a player starts walking mid animation, while the legs weren’t near the start or end of the animation, it’ll overlap and cause the animation to look like it’s jumping since both animations raise their legs at the same time.
This has happened to me before, when I used an open source directional walking system, but now I’m making my own, so I can get off the habit of looking for scripts that are pre-made and make my own.
I’ve tried to make the FadeTime of the animations be how many seconds are left for the walking forward animations to finish, with this line:
local duration = animations_table.WalkForward.Length - animations_table.WalkForward.TimePosition
but that didn’t work, it really just caused more problems than anything…
Example of the problem:
Script I’m using (I know it’s kind of messy the way I did it, but I’ll get to fixing that in a bit, now I’m just trying to fixing this bug done…)
-- // SERVICES \\ --
local user_input_ser = game:GetService("UserInputService")
local rep_ser = game:GetService("ReplicatedStorage")
local run_ser = game:GetService("RunService")
-- // INSTANCES \\ --
local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local hum = chr:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local root_part = chr:WaitForChild("HumanoidRootPart")
-- // ANIMATIONS \\ --
local animations_folder = script:WaitForChild('Animations')
local animations_table = {
WalkForward = hum:LoadAnimation(animations_folder.WalkForward),
WalkLeft = hum:LoadAnimation(animations_folder.WalkLeft),
WalkRight = hum:LoadAnimation(animations_folder.WalkRight),
Running = hum:LoadAnimation(animations_folder.Running),
Jump = hum:LoadAnimation(animations_folder.Jump),
Fall = hum:LoadAnimation(animations_folder.Fall)
}
for i, anim in pairs(animations_table) do
anim:Play(0,0,0)
end
run_ser.RenderStepped:Connect(function()
local movement_direction = root_part.CFrame:VectorToObjectSpace(root_part.AssemblyLinearVelocity)
local forward = math.abs(math.clamp(movement_direction.Z / hum.WalkSpeed, -1, -0.001))
local backward = math.abs(math.clamp(movement_direction.Z / hum.WalkSpeed, 0.001, 1))
local left = math.abs(math.clamp(movement_direction.X / hum.WalkSpeed, -1, -0.001))
local right = math.abs(math.clamp(movement_direction.X / hum.WalkSpeed, 0.001, 1))
local duration = animations_table.WalkForward.Length - animations_table.WalkForward.TimePosition
if forward > 0.4 then
if animations_table.WalkForward.IsPlaying == false then
animations_table.WalkForward:Play(0.1)
end
end
if forward < 0.4 then
if animations_table.WalkForward.IsPlaying == true then
animations_table.WalkForward:Stop(0.1)
end
end
if right > 0.4 then
if animations_table.WalkRight.IsPlaying == false then
animations_table.WalkRight:Play(duration)
end
end
if right < 0.4 then
if animations_table.WalkRight.IsPlaying == true then
animations_table.WalkRight:Stop(0.1)
end
end
if left > 0.4 then
if animations_table.WalkLeft.IsPlaying == false then
animations_table.WalkLeft:Play(duration)
end
end
if left < 0.4 then
if animations_table.WalkLeft.IsPlaying == true then
animations_table.WalkLeft:Stop(0.1)
end
end
end)
I’m not looking for entire scripts to fix this, and instead maybe a suggestion to guide me to fixing this!