Jrayp / Moku

Map utility & auto-tile module for the Defold game engine
MIT License
36 stars 2 forks source link

Moku's path finder works slowly, making the game hiccup #15

Closed hanthuyen8 closed 5 years ago

hanthuyen8 commented 5 years ago

Whenever I use the path_finder function, moku takes a lot of time to process, causing the game to hiccup. If possible, expect you to find a solution. Thank you.

Jrayp commented 5 years ago

I don't work on moku any more unfortunately. I have moved on from defold to another engine.

How slow Moku is, is clearly going to depend on what youre doing. How large and complex is your map? How many times are you calling the function per frame, how are you determining the cost of each cell traversed?

If you check the demo for instance moku works without a problem (though with a small map). I never did any kind of performance profiling, so I'm not sure what it can handle.

With all of that said Moku was an exercise in lua for me. It's literally the first thing I wrote in lua, and i can NOT guarantee that it is very performant. Only that it is functional.

hanthuyen8 commented 5 years ago

Dear Mr. Jrayp.

I am very sorry for not replying to you earlier. Because I have to focus on solving many private issues, including the odd errors in my game. Now everything is fine, so I'm happy to tell you about it.

In my game, the characters will move in a tilemap. An NPC will automatically find its way to certain locations on the map, once that location is reached, the NPC will find its way to the next point.

So the frequency of using Path-finding function will not be much.

About tilemap, it has a size of 50x50 tiles, each tile is 48x48 pixels. And there are only 2 types of tiles on it: passable and unpassable.

But every time NPC uses Path-finding function, the game has been stopped for a few seconds (everything stops, including animation and sound).

At first I thought it was because of slow processing by Moku, so I tried using other modules. But it's still the same, even worse because they're full of errors.

Finally, I used "Jumper Path-finding" and decided to deploy coroutine within it to separate its processing into multiple frames. And now the problem has been solved, the game has run smoothly.

After trying many modules, I think your Moku is the best. Thank you for creating a great module.

I wish you and your family a good health and happy life.

Best regards.