How do I make an NPC walk on the set of tiles? (Pathfinding)

Hello, so I need an npc to go through the path and it consists out of small tiles, which npc has to do :MoveTo() to. But I don’t know how to make these paths in order, so the NPC walks exactly to each path in the right order.

If you are still confused, we are able to see this system implemented in to Theme Patk Tycoon 2. The NPC has to basically walk on the selected path.
Media:
5704e644b3403b3bd84a6b1210671c19 (1)

So, how am I able to implement this? Thank you

2 Likes

Theme park tycoon does not use the default pathfinding. They more likely used A* pathfinding in order to have a path finding system that can accommodate their grid based tile system, and identify the path tiles from the grid data.

1 Like

Thanks! I am not sure how to understand this though, since I am not that good at python? Could you make an example in lua?

Sure, it’s already all available on the dev forum #resources:community-resources

I primarily learnt from @shvkti open source game. If you compare the python code and his code you will definitely see the similarities and be able to reap the explanations from the blog post withthe application code in the open source game which tbh you can copy and paste if you understand it.

Also for NPC movement I recommend no humanoids, as they are pretty laggy as they use physics to travel, lots of physics = lag due to collisions and such. Tweening is recommended like in theme park tycoon they don’t collide with each other.

1 Like

Thanks. I am pretty sure I still need to use humanoid due to me making a fight system between the npcs. But your answer is appreciated a lot. Thank you!