Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is there a less demanding way of making pathfinding?

I'm about to start working on some enemy ai that will run all of the enemies in a level from the client, is there any way of optimizing the pathfinding service properly? In the end I'd like to be able to have about 30 different enemies and run smoothly, ideally something on the lines of DOOM's ai (unique enemies.).

Is PathfindingService a viable option, or will I need to create an alternative?

(Also, the tutorial on the wiki - while not expressly stating it - makes it look server-based, rather than client-base.)

1 answer

Depends on what kind of map you are making.

If it is grid based, then you can very easily grab some extra performance by implementing a less demanding pathfinding algorithm (like a* for example).

If it is a static map, with no dynamic elements, you can make a node based pathfinding system which will greatly lessen the cost of determining the path.

Otherwise, it will be difficult to create a better alternative in Lua. The pathfinding service is fairly robust for dynamic environments and benefits from having root access to different physical aspects of the world.

8 comments

0

It'll be a static map, asides from doors opening. I'd also like to be able to make something equivilant to a cacodemon, but the current Pathfinding only calculates for walking. Any suggestions for node based? Tutorials or such?

0

sorry, unique levels, with static maps*

0

It would be good to dive into graph theory a bit, specifically creating data structures to store the nodes and such. As for the actual pathfinding, A* is most likely your best bet. I don't know of any specific tutorials, but there is tons of documentation on the web for this kind of stuff.  Also, take a look into shortest path problems (as this is essentially what you are trying to solve)

0

A little warning though, I wouldn't suggest tackling this challenge unless you have a solid background in programming. This is a fairly advanced topic, especially if you are just starting out.

0

After, a fair bit of looking into it, I've discovered a few pre-existing algorithms on Roblox, but with the amount of NPC's I want moving at once, this creates a small problem, I iterate through a table to control them, should I instead clone a script and tie it to the individual? I'm going to go back and work through the code to understand it (and hopefully simply some aspects), but is there any

0

Threading in one script would probably be more efficent than a script for each AI

0

Darn. Its pretty inefficient in one :/ Ah well, to the research!

0

You'll find that pathfinding is pretty demanding

This discussion is preserved as it was. New answers, comments, and votes are closed.