Unexplainable Rig Movement

I have multiple rigs that are supposed to move from one waypoint to the next. However, I am noticing that one of them looks like it is trying to skip a waypoint, and is moving partially rotated. He starts out walking fine, then abruptly starts walking weirdly. I can’t figure out why this is happening, since none of the other rigs are doing this.

Here is the function I use to control the movement of the rigs from waypoint to waypoint (It is a module script in ServerScriptService):

function mob.Spawn(name, quantity, map)
	local mobExists = serverStorage.SpawnMobs:FindFirstChild(name)
	
	if mobExists then
		for i=1, quantity do
			task.wait(1)
			local newMob = mobExists:Clone()
			newMob.HumanoidRootPart:PivotTo(workspace.Waypoints[1].CFrame)
			newMob.Parent = workspace.Mobs
			newMob.HumanoidRootPart:SetNetworkOwner(nil)
		
			for i, object in ipairs(newMob:GetDescendants()) do
				if object:IsA("BasePart") then
					object.CollisionGroup = "Mob"
				end
			end
		
			coroutine.wrap(mob.Move)(newMob, map)
		end
		
	else
		warn("Requested Mob Does Not Exist", name)
	end
end
1 Like

In case anyone is wondering, the animation shouldn’t be causing this, because I have the same animation in another rig, and it doesn’t do this.

Quite an odd and interesting issue I see here… It seems to be caused my unwanted collissions with the rig’s feet and the ground. Maybe try turning collissions off?

I would also recommend you giving us the script that handles the pathfinding. Else, we are unable to assist you with your issue.

When I turn collisions off, this happens:

The script that handles the pathfinding is given above, but here it is again:

function mob.Spawn(name, quantity, map)
	local mobExists = serverStorage.SpawnMobs:FindFirstChild(name)
	
	if mobExists then
		for i=1, quantity do
			task.wait(1)
			local newMob = mobExists:Clone()
			newMob.HumanoidRootPart:PivotTo(workspace.Waypoints[1].CFrame)
			newMob.Parent = workspace.Mobs
			newMob.HumanoidRootPart:SetNetworkOwner(nil)
		
			for i, object in ipairs(newMob:GetDescendants()) do
				if object:IsA("BasePart") then
					object.CollisionGroup = "Mob"
				end
			end
		
			coroutine.wrap(mob.Move)(newMob, map)
		end
		
	else
		warn("Requested Mob Does Not Exist", name)
	end
end
1 Like

By pathfinding script I mean the script that actually makes the entity move. You just gave the the script that inserts the entity and runs the move script.

I also do see some great improvement after turning off collissions.

function mob.Move(mob, map)
	local humanoid = mob:WaitForChild("Humanoid")
	local waypoints = workspace.Waypoints
		
	for waypoint=1, #waypoints:GetChildren() do
		humanoid:MoveTo(waypoints[waypoint].Position)
		humanoid.MoveToFinished:Wait()
	end
		
	mob:Destroy()
	
end
1 Like

Hmm… odd… the script looks completely fine. It seems that the issue is being caused by some object that make it jitter because this certainly does not seem like an issue with the script.

Other than the waypoints, there aren’t any parts on the path that would be causing this (other than maybe the paths, but that seems unlikely), and the waypoints aren’t collidable.

It is strange, because when I remove the animation, it almost looks like it is colliding with the spawn waypoint, which shouldn’t be possible, because collisions are set to false on the waypoints.

Is it the same case for every single entity or is it just this one? If it’s just this one then maybe try remaking the rig? It could be that one of the accessories could have collision.

I can try remaking the rig. As to the part where accessories could have collisions, I have tried turning collisions off for just the accessories, and it didn’t solve the jittering problem.

This is quite odd… I am still confused as to how it is still jittery even though the code logic seems to be quite fine?
How many waypoints are there?

Including the Start and Finish waypoint, 16.

Maybe try decreasing the amount. Only add on corners. I think the issue could be the waypoints placing but yet I could be wrong…

The only waypoints I have placed are on corners. Maybe the issue with him turning before he reaches the checkpoint is because he can’t get to it in time before he moves to the next (not sure why he would do this, but that is the only thing I can think of that would cause him to skip a waypoint midway).

As to the jittering, I don’t think the waypoints have anything to do with this, so I am going to try and recreate the rig, and see if I can fix the issue.

I just found out that the humanoid was set to R6 (no clue how that happened), so I fixed that, and the jittering is no longer happening, but this is now happening instead:

I don’t think :GetChildren() guarantees order. Perhaps rename your waypoints to numbers like 1..10 and do something like:

for i in 1, #waypoints:GetChildren() do
     waypoints[tostring(i)] etc...
end

edit: syntax whoops (still did not solve OP’s problem though)

for i = 1, #waypoints:GetChildren()...

That is just caused by wrong waypoints being selected. One thing you could do is to name them according to their priority and use a for i loop to iterate over them accordingly.

You could try setting Anchored = false and CanCollide = false to all BaseParts inside the Rig, including Accessories