Pathfinding jittery/stuttering walk animation solution

After encountering this issue myself I couldn’t find any solutions that worked for me by searching for it on the DevForum, methods such as setting the NPC Network Ownership did not work either, so after trying to figure out a solution myself I came up with this one and I wanted to share it with anyone that is having similar issues.

For this tutorial I’m using SimplePath, a great Pathfinding module which I am also using in the game I am working on.

This code is just an example of what to do, should work with the Roblox pathfinding with minimal changes

local isWalkPlaying = false -- Used to make sure the walk animation doesn't play on loop because Running fires many times with Pathfinding.
local isPathfinding = false -- Used to make sure that Pathfinding isn't running anymore and the script can continue to play the idle animation.

Humanoid.Running:Connect(function(speed) -- Listen for the Running event which returns the speed of the character.
	isPathfinding = NPC:GetAttribute("Pathfinding") -- Get the current state of Pathfinding attribute.
	if speed > 0 then -- If Speed is greater than 0 then the walk animation can continue.
		if isWalkPlaying == false then -- Check if the walk animation is already playing.
			isWalkPlaying = true
	elseif speed <= 0 and isPathfinding == false then -- Checks if the NPC is still pathfinding/walking to the point, if not it plays the idle animation and stops the running animation.
		isWalkPlaying = false

Path.Reached:Connect(function() -- Detects when the NPC has reached the target position.
	NPC:SetAttribute("Pathfinding", false) -- Sets pathfinding Attribute to false.

NPC:SetAttribute("Pathfinding", true) -- Sets the Pathfinding attribute to true to prevent Idle animations from playing.
Path:Run(targetPosition) -- Pathfinding function from SimplePath.

Place file with the whole code:
pathfindingExample.rbxl (77.8 KB)






This is one of the solutions that did not work for me and many others, the before video already has the network ownership set to the server but the issue is still there.

Edit to the main thread:
I’ve added an example file with the module and the script in it.

well yeah :SetNetworkOwner(nil) is a physics task manipulation type stuff. you failed to debounce your animation .Running runs when you move and when you stop if you dont have conditions set to stop the animation from playing both times itll result in jitters.

1 Like