NPC are not moving correctly

I’m doing a Tower Defense but for some reason when I use Humanoid:MoveTo() it doesn’t go exactly in the coordinates, when the boss comes you can see a big difference because of the size. can anyone help me to solve this?

8 Likes

Where is the HumanoidRootPart of the boss?
If that part reaches the waypoint then it’ll recalculate. If it isn’t in the center then you need to move it.
I’m not sure if when that part is bigger it recalculates when the edge hits the waypoint, or when the Position of that part hits it.

4 Likes

If this is pathfindingservice, have you set up path params?

local pathparams = {
--insert height, can climb and jump here
["AgentRadius"] = --put the width here, in studs
["WaypointsSpacing"] = math.huge --keep this to avoid random problems
}
:CreatePath(pathparams)
2 Likes

it’s just the normal Humanoid:MoveTo()

2 Likes

That’s the issue, that just takes the closest path and ignores if there’s an obstacle in front of it. Now just trial and error with pathfinding for 3 hours and your issue will be fixed! I’m not kidding, you have no other option, aside from pathfinding or a pathfinding module like simple path lol

1 Like

I would think that you should change the BOM not as @bloodbonniekingnoob1 says when putting it in infinity, what do you think?
you must establish the value of materials, the one of the route puts it low and the rest you put it in math.huge, sorry because ABSOLUTELY NOBODY HELPED YOU IN THIS SUBJECT, in case the above is not the solution, then I would recommend it; Do not use the Pathfinding service and make parts of the entire route and move to that point, also remember that as soon as you get a little closer to the point, it continues to the next point, that is, it does not reach the point itself, but continues with the other, that explains why it does not reach the exact point

1 Like

If you haven’t already, I would also mess with Costs in Pathfinding. Basically tells the Pathfinding when computing a path, to not walk on these materials (when using math.huge). probably will be extremely helpful for you to make sure your NPCs are staying on path and make sure they prioritize staying on path verse shorter route! (Would be a recommendation to do this, although my bad, I thought you were using PathFinding)

2 Likes

They aren’t using pathfinding service.

2 Likes

OHHH, I already understood the error, it’s not the route or the cost of materials because I suppose you already did that, rather stabilize the Pivot in the middle of the model

2 Likes

This is the solution character limit… help me with my Scottish theme, give me some advice

2 Likes

AJA, entonces porque se te ocurrio poner esto;

2 Likes

I mean, who would think that the route service is going to follow the path in this way? I mean, what are you thinking?

2 Likes

What? Pathfinding service should go to that specific waypoint, and if it didn’t, like @OfficialPogCat said they can use costs.

I’m trying to be friendly here since it seems like you’re attacking me in every reply you make.

3 Likes

HOW WILL YOU GO TO THAT POINT IF IT WOULD NOT BE THE SHORTEST ROUTE? waza?

2 Likes

Look, don’t pay attention to those guys, or to me because @Scottifly has the solution

1 Like

My bad, I thought you were using PathFinding. This isn’t related to your issue, but could become an issue as Humanoid:MoveTo() has a 8 second limitation. Do as you want idc, just feel bad if you didn’t know this limitation which is why I thought you were using Pathfinding (Pathfinding using waypoints so this doesn’t really become an issue within pathfinding, as it adds more waypoints if it can’t reach a point within 8 seconds). But you can do it the way you are currently as long as you respect this limitation (boss was moving slow so for slow entities you might have issues)

3 Likes

They are using waypoints via a part, next part etc. Froward, left and right are the shortest paths since it won’t go for the exit directly. They could just go to the exit if they used costs since it wouldn’t go off track.

2 Likes

What are the recommendations for solving this? ahorita tengo el mismo problema encerre el MoveTo() en un loop y no work
edit: Why MoveTo() Not Working

1 Like

Using Pathfinding is a well solution but sometimes can’t always be used. Setting the NetworkOwnership of the moving model to nil (The server) can help, and finally doing some repeat task.wait until magnitude is around 5 of its goal checks instead of using Humanoid.MoveToFinish. There is many different things as well to try in this case and I only named a few, doing more searches can help fix your issue or doing trial and error tests which I find most useful in my case.

2 Likes

I already fixed this problem

local Finished = false
local EndEvent 

for i,v in pairs(WayPoints) do
	if Char.Parent and Hum.Health > 0 then
		Char.MovingTo.Value = v.Instance
		
		local ToPos = v[1].Position
		Hum:MoveTo(ToPos,v.Instance)
		
		local Part = GetPart()
		Part.Parent = workspace
		Part.Position = ToPos
		
		EndEvent = Hum.MoveToFinished:Connect(function(reached)
			if reached then
				Finished = true
           else
				Hum:MoveTo(ToPos)
			end
		end)
		repeat
			if not Char.Parent or Hum.Health <= 0 then
				Finished = true
			end
			task.wait()
		until Finished
		EndEvent:Disconnect()
		Finished = false
	end
end
1 Like