Pathfinding for an NPC to only follow assinged paths

Hi!

Im currently making a wandering trader for my game, and we have paths made of mud around the map and im not sure how to make him follow them.|

should I
A) make an invisible part made path and make them follow it, if so how
B) make them follow a terrain path, if so how

tl;dr, how do I make an NPC follow paths through a large map

Please search around before making posts as there are many tutorials on youtube on this. You’d start off here: Character Pathfinding | Roblox Creator Documentation

I did and found that page, but I didnt quite understand it so I asked here to see if anyone had more experience and could provide help

This has surprisingly 113k views and 3k likes… wow… anyways, this should help you understand it. Have you tried watching this?

Ive watched this and it doesnt provide what im looking for

you COULD use pathfinding modifers. BUT they’re in beta. So they only work in studio, not in-game. Soo yeah. I’d suggest for you to wait for pathfinding modifers to be out of beta so they work outside of studio.

If you don’t want to wait for pathfinding modifers to be out of beta. Then make a custom path. Heres an example file that you can use in your game:
Custom path test.rbxl (64.9 KB)

1 Like

That isn’t what he’s looking for.

Its actually pretty easy.(I assume you already know how to pathfind

Simply colour in the terrain you want the NPC to work on e.g. Concrete or Mud.
Then create a table of all the costs of the materials.

Then when creating the path simply add the table.

local PathfindingService = game:GetService("PathfindingService")
 
local path = PathfindingService:CreatePath({
	Costs = {
		Water = 20,
		Mud = 5,
		Neon = math.huge
	}
})

Th higher the cost the less likely it will walk over it.
Compute the path then move the NPC alng the path. The article goes into it. I suggest looking carefully bat the code and understanding wha each line does.

You could make a part cost system but usually its a lot harder to setupimo

1 Like

they DON’T work in game. They’re in Beta so they work in studio ONLY! Theres no point of using them in your game because they dont work outside of studio. Just wait for it to be out of beta.

I am well aware of that. There is no reason not to make it in studio.