Using Parallel Lua for Pathfinding?

I am creating an AI that needs to constantly pathfind to chase a target.

Besides trying to cache the position or only use pathfinding when there isn’t a direct line of sight, I am trying to see if I can take advantage of Parallel Lua to make the calculations faster.

Does anyone have any experience on how to go about this?

When I tried to it said that “Function Path.ComputeAsync is not safe to call in parallel”, does this mean it just can’t be done or I am doing it wrong?

You need a BindableFunction to accomplish this, in an actor. You can’t do the ComputeAsync in parallel, but you can send a table to the function and move to the points in parallel.

Can you provide an example please? (If it even makes a difference to begin with) I’ve been looking for an alternative to this as well.

That method is outdated. You should refer to this instead:

How could a character move to the points in parallel?

wouldnt the only benefit of doing parallel lua this way be to run the path calculations in parallel?

Since you cant do that with A* there is no way to do ai unless you make a custom ai right?

I ended up just doing my own pathfinding with a barebones A* (with nodes manually placed all over the map). From my benchmarks it was about 100x faster than using Roblox’s one, however it does not update to changing environments so it depends on what you need it for. It ran so fast I didn’t need to put it in parallel for my use case.

1 Like