Jittery / visually buggy movement animations (especially on turns)

you know it baby im back with another problem !!!
clip on youtube since devforum hates any video longer than 10 seconds https://www.youtube.com/watch?v=L9_52ZbAddY
animations for the body is all handled by one local script in the model :3 hell yeah organization!

local uis = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")


-- movement tracks
local walk = script:WaitForChild("Walk")
local walkTrack = humanoid.Animator:LoadAnimation(walk)
local idle = script:WaitForChild("Idle")
local idleTrack = humanoid.Animator:LoadAnimation(idle)
local trot = script:WaitForChild("Trot")
local trotTrack = humanoid.Animator:LoadAnimation(trot)
local run = script:WaitForChild("Run")
local runTrack = humanoid.Animator:LoadAnimation(run)
local crouch = script:WaitForChild("Crouch")
local crouchTrack = humanoid.Animator:LoadAnimation(crouch)
local sneak = script:WaitForChild("Sneak")
local sneakTrack = humanoid.Animator:LoadAnimation(sneak)

-- task identifiers
local emote = false
local speedwalk = true
local speedtrot = false
local speedrun = false
local speedsneak = false

-- movement script

uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.E and speedsneak == true then -- begin walking
		speedwalk = true
		speedsneak = false
		
		speedtrot = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.E and speedwalk == true then -- begin trotting
		speedwalk = false
		speedtrot = true
		
		speedsneak = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.E and speedtrot == true then -- begin running
		speedtrot = false
		speedrun = true
		
		speedsneak = false
		speedwalk = false
	elseif input.KeyCode == Enum.KeyCode.Q and speedrun == true then -- slow to trot
		speedrun = false
		speedtrot = true
		
		speedsneak = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.Q and speedtrot == true then -- slow to walk
		speedtrot = false
		speedwalk = true
		
		speedsneak = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.Q and speedwalk == true then -- slow to sneak
		speedwalk = false
		speedsneak = true
		
		speedtrot = false
		speedrun = false
	end
end)

humanoid.Running:Connect(function(speed)
	if speedwalk == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0.99 and emote == false then
			idleTrack:Stop()
			walkTrack:Play()
			humanoid.WalkSpeed = 12
		elseif speed < 0.99 and emote == false then
			idleTrack:Play()
			walkTrack:Stop()
		end
	end
	if speedtrot == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0.99 and emote == false then
			idleTrack:Stop()
			trotTrack:Play()
			humanoid.WalkSpeed = 20
		elseif speed < 0.99 and emote == false then
			idleTrack:Play()
			trotTrack:Stop()
		end
	end
	if speedrun == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0.99 and emote == false then
			idleTrack:Stop()
			runTrack:Play()
			humanoid.WalkSpeed = 35
		elseif speed < 0.99 and emote == false then
			idleTrack:Play()
			runTrack:Stop()
		end
	end
	if speedsneak == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0.99 and emote == false then
			crouchTrack:Stop()
			sneakTrack:Play()
			humanoid.WalkSpeed = 7
		elseif speed < 0.99 and emote == false then
			crouchTrack:Play()
			sneakTrack:Stop()
		end
	end
end)

idleTrack:Play()

-- END OF MOVEMENTS

-- EMOTES

-- EMOTE LIST
local sit = script:WaitForChild("Sit")
local sitTrack = humanoid.Animator:LoadAnimation(sit)

uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.R then
		if emote == false then
			emote = true
			sitTrack:Play()
			humanoid.WalkSpeed = 0
			humanoid.JumpPower = 0
			print("now sitting")
		else
			emote = false
			sitTrack:Stop()
			humanoid.WalkSpeed = 12
			humanoid.JumpPower = 35
			print("now unsitting")
		end
	end
end)

extra notes: animations “idle” and “crouch” are set as idle animations, “walk”, “trot”, “run”, and “sneak” are set as movement animations and all designed to loop smoothly.

this would be an issue with one of two main things.

there is a problem with the code (most likely) where cframes / bones are overlapping
animations are not fully loaded in (I don’t think this is the cause)

1 Like

I’m not sure what you mean. All animations are made in the Animation Editor, exported, and then uploaded as “Animation” as child of the script. I specifically wrote the code in a way so that they wouldn’t play at the same time (and after lots of testing, they don’t). Did you watch the video? It’d help express my problem - which is that the animations all play perfectly fine, however when the character turns, they jitter/pause for a moment.
(Sorry if I’m misunderstanding, I am a beginner at Luascript :sweat_smile:)
Edit: The only sort of animation that uses CFrame on the model is the head-turning, I think, which is a whole different issue on another thread haha

1 Like

This problem has not been solved yet.

Have you checked that no animations are overlapping? A good way to do this is use the GetPlayingAnimations() on the humanoid to check if animations are overlapping

1 Like

the only thing that looks like is happening is that the walk animation interrupts itself when turning

edit: ALSO the animations werent experiencing such jittery movement before i implemented q/e to slow down and speed up, so there must be something in my script (shown in original post) causing animations to bug out a little while moving.

edit 2: the script for movement used to look something like this and did not experience pause in animations

-- Very basic walking animation script by GnomeCode
local uis = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")
local emote = false

-- Remeber to select the animtion object and set the id to your own!
local walk = script:WaitForChild("Walk")
local walkTrack = humanoid.Animator:LoadAnimation(walk)

local idle = script:WaitForChild("Idle")
local idleTrack = humanoid.Animator:LoadAnimation(idle)

humanoid.Running:Connect(function(speed)
	if speed > 0 and emote == false then
		if not walkTrack.IsPlaying and idleTrack.IsPlaying then
			idleTrack:Stop()
			walkTrack:Play()
		end
	else
		if walkTrack.IsPlaying and not idleTrack.IsPlaying then
			idleTrack:Play()
			walkTrack:Stop()
		end
	end
end)

idleTrack:Play()

-- emote list :3
local sit = script:WaitForChild("Sit")
local sitTrack = humanoid.Animator:LoadAnimation(sit)

uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.R then
		if emote == false then
			emote = true
			sitTrack:Play()
			humanoid.WalkSpeed = 0
			humanoid.JumpPower = 0
			print("now sitting")
		else
			emote = false
			sitTrack:Stop()
			humanoid.WalkSpeed = 12
			humanoid.JumpPower = 35
			print("now unsitting")
		end
	end
end)

I might have to wait until I fix this other issue first, but I do notice that the animation issue is happening with the head-turning as well, which is the only CFrame-related animation occurring on the player.


So to sum up this bit of information:
The animations jitters, pause, or otherwise cut half-way through when the player is turning the body or the head.

I made some changes to the script to account for some weird visual errors I was experiencing with the emotes (such as sitting). I was able to fix some aspects of the animations, but they still pause, hesitate, bug out, whatever haha. So the issue still stands. It’s hard to notice it at first until the player starts trotting & running.
Here’s a clip of current gameplay:


Here’s what the script looks like now:

local uis = game:GetService("UserInputService")
local character = script.Parent
local humanoid = character:FindFirstChild("Humanoid")


-- movement tracks
local walk = script:WaitForChild("Walk")
local walkTrack = humanoid.Animator:LoadAnimation(walk)
local idle = script:WaitForChild("Idle")
local idleTrack = humanoid.Animator:LoadAnimation(idle)
local trot = script:WaitForChild("Trot")
local trotTrack = humanoid.Animator:LoadAnimation(trot)
local run = script:WaitForChild("Run")
local runTrack = humanoid.Animator:LoadAnimation(run)
local crouch = script:WaitForChild("Crouch")
local crouchTrack = humanoid.Animator:LoadAnimation(crouch)
local sneak = script:WaitForChild("Sneak")
local sneakTrack = humanoid.Animator:LoadAnimation(sneak)

-- task identifiers
local emote = false
local speedwalk = true
local speedtrot = false
local speedrun = false
local speedsneak = false
local currentspeed = false

-- movement script

uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.E and speedsneak == true then -- begin walking
		speedwalk = true
		speedsneak = false
		
		speedtrot = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.E and speedwalk == true then -- begin trotting
		speedwalk = false
		speedtrot = true
		
		speedsneak = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.E and speedtrot == true then -- begin running
		speedtrot = false
		speedrun = true
		
		speedsneak = false
		speedwalk = false
	elseif input.KeyCode == Enum.KeyCode.Q and speedrun == true then -- slow to trot
		speedrun = false
		speedtrot = true
		
		speedsneak = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.Q and speedtrot == true then -- slow to walk
		speedtrot = false
		speedwalk = true
		
		speedsneak = false
		speedrun = false
	elseif input.KeyCode == Enum.KeyCode.Q and speedwalk == true then -- slow to sneak
		speedwalk = false
		speedsneak = true
		
		speedtrot = false
		speedrun = false
	end
end)

humanoid.Running:Connect(function(speed)
	if speedwalk == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0 and emote == false then
			idleTrack:Stop()
			walkTrack:Play()
			humanoid.WalkSpeed = 12
			currentspeed = 12
		elseif emote == false then
			idleTrack:Play()
			walkTrack:Stop()
		end
	end
	if speedtrot == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0 and emote == false then
			idleTrack:Stop()
			trotTrack:Play()
			humanoid.WalkSpeed = 20
			currentspeed = 20
		elseif emote == false then
			idleTrack:Play()
			trotTrack:Stop()
		end
	end
	if speedrun == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0 and emote == false then
			idleTrack:Stop()
			runTrack:Play()
			humanoid.WalkSpeed = 35
			currentspeed = 35
		elseif emote == false then
			idleTrack:Play()
			runTrack:Stop()
		end
	end
	if speedsneak == true then
		walkTrack:Stop()
		idleTrack:Stop()
		trotTrack:Stop()
		runTrack:Stop()
		crouchTrack:Stop()
		sneakTrack:Stop()
		if speed > 0 and emote == false then
			crouchTrack:Stop()
			sneakTrack:Play()
			humanoid.WalkSpeed = 6
			currentspeed = 6
		elseif emote == false then
			crouchTrack:Play()
			sneakTrack:Stop()
		end
	end
end)

idleTrack:Play()

-- END OF MOVEMENTS

-- EMOTES

-- EMOTE LIST
local sit = script:WaitForChild("Sit")
local sitTrack = humanoid.Animator:LoadAnimation(sit)

uis.InputBegan:Connect(function(input, gpe)
	if gpe then return end
	if input.KeyCode == Enum.KeyCode.R then
		if emote == false then
			emote = true
			sitTrack:Play()
			humanoid.WalkSpeed = 0
			humanoid.JumpPower = 0
			print("now sitting")
		else
			emote = false
			sitTrack:Stop()
			humanoid.WalkSpeed = (currentspeed)
			humanoid.JumpPower = 35
			print("now unsitting")
		end
	end
end)

Conversation moved here, this specific issue was solved.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.