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
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.
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
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
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.
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:
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.