I’m currently working on a single player story / freeroam game, but I am struggling a little bit with the NPC system I am creating.
So, one of the first features I’ve started working on is NPC’s having items, such as clothing. But, to purchase the items the NPC’s are going to drive to the clothing store right. So, let me stop rambling. I am attempting to calculate the path of the NPC to drive. So they get into the car, lets say it’s just the car is on the road.
I need some help learning on how to calculate the path, I do not want to use path finding service because It is just going to go through the buildings / through the empty plots. I am attempting to have it where the car pulls to an intersection, lets call that intersection point A, they need to get to point B (view diagram below). Does anyone know a good algorithm that I could learn to calculate the best path for this? And if so, is there a specific way I should implement it in roblox?
A ----------- D
C ----------- X
L ----------- B
You can use PathfindingService to achieve this, for the parts you don’t want the NPC to walk on, add a pathfinding modifier there and make the cost of that math.huge, that’ll exclude it and will make the NPC never want to go there.
I know that they said that, but it’s way easier and more accurate to use a completely functionally, well tested and built-in pathfinding algorithm rather than one you just made. (S)He may have never heard of PathfindingModifiers which could be the reason (s)he didn’t want to use PathfindingService.
There’s actually an open sourced Roblox showcase that Roblox published years ago: The cars and NPCs follow the roads and sidewalks, and the NPCs can drive.
It’s a little bugged, but you may be able to learn how they did it by editing it.