How to make npc follow player anywhere?!

I am working on Pathfinding and using SimplePath to simply make paths.

End Goal:

I want that where ever the player is able to go, the NPC can follow them.
(Assuming no moving parts or ladders (eventually I want ladders too))

Problem:

NPC doesn’t always go where player goes. The player is able to make much bigger jumps than the NPC and the player can also make “clutch jumps” around parts.

I have the Humanoid WalkSpeed and JumpPower the same. I also tried changing the AgentParameters to higher and lower numbers and still doesn’t work

pathfinding_example.rbxl (52.5 KB)

Here’s test file you can see for yourself.

I’m thinking it’s the ComputeAsync algorithms fault and the only way to ensure the NPC can follow the player anywhere is to have it teleport to the player when it gets stuck.

Any ideas are appreciated thanks.

2 Likes

You could put the NPC’s ending point anchored to the player? and once it hits the player the path resets again to the player and if this doesn’t work you can try making your own pathfinding script there is a lot of tutorials on youtube talking about it and one of them is thedevking and as for the jumps you can customize your script to make him jump over the obstacles and as well as the pathfinding service chooses the quickest way to get to their point in our case which is the player so it should go with the player in the pathfinding service (Again it is really easy to make a pathfinding service even if you follow a tutorial)
here are some articles talking about it. Character Pathfinding | Roblox Creator Documentation and
PathfindingService | Roblox Creator Documentation and here is a great tutorial for it How To Use Pathfinding Service In Roblox (as well as thedevking on youtube)

1 Like

Yes I already did all that, I am asking how to ensure that the NPC can make the same jumps the player can.

Because the player is able to make jumps that the PathfindingService won’t calculate. As you can see it the example file.

1 Like

I’d suggest doing an If statement so If the player’s Humanoidstatetype changed to “Jump” then wait a few seconds (aka for the NPC to arrive at its destination then make the NPC’s Humanoidstatetype to Jump
(This would though make the NPC seem a bit late) and you can calculate how much the player and the NPC are far away from (magnitude) and if it is maybe 50 studs away then teleport the NPC to the player (I can’t really think of any other solution)

1 Like

Listen … to … my… problem…

The ComputeAsync will not compute a path with a jump in it that it thinks the NPC can’t do. Many of those jumps a player can do though. Meaning that the NPC will not be able to continue to follow the player.

1 Like

Then just calculate the magnitude between the player and the NPC and if the player was far enough then the NPC would teleport other than that I can’t do anything else.

1 Like

Sometimes the dummy will not be able to reach the goal even if it is traversable. Unfortunately, this is how PathfindingService works and there is nothing you can do about it. One way to check if some obstacle is traversable or not is to enable “Show Navigation Mesh” through studio settings.

image


If you can see arrows between two parts, it means the NPC will attempt to jump at that location.

4 Likes

Okay so the only option is would be to teleport the NPC?

Would there be anyway to make a manual system, like if ComputeAsync fails I manually make the character jump to a spot where ComputeAsync won’t fail?

Or how about this idea?: When ComputeAsync fails, I make the NPC follow the exact path of the player using the “breadcrumb” method. Obviously this won’t account for fastest path but will at least get the NPC unstuck.

1 Like

Sure you can give it a try. You would need to account for the SimplePath.ErrorType.TargetUnreachable and the SimplePath.ErrorType.ComputeError error types for the NPC.

1 Like