Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The best way to deal with dynamic obstacles? #5

Closed
its-danny opened this issue Feb 2, 2012 · 1 comment
Closed

The best way to deal with dynamic obstacles? #5

its-danny opened this issue Feb 2, 2012 · 1 comment

Comments

@its-danny
Copy link

This isn't so much an issue as a question. D:

So, I'm using this in a game I'm working on (in Crafty.js) and have it working so that enemies follow the player. The problem is that they all choose almost the same path depending on where they are, resulting in them stacking on top of each other. I've tried recalculating the graph every time an enemy movies, and in turn recalculating the paths for each enemy. That somewhat worked, but ran pretty slow.

How would you suggest going about this?

@bgrins
Copy link
Owner

bgrins commented Feb 2, 2012

Danny,
It sounds like you are already calculating the best path for each individual enemy, but the slow part is refreshing the map in between each calculation. What if instead of rebuilding the whole map, you just updated the old/new spots for the previous enemy? After each pathfinding search, if the enemy moves, then mark his old spot as now 'open' and his new spot as now 'closed' and pass this new map into the next search. Would that take care of the problem?

Oh, and if you want to share a link to your game when you finish it up, I'll post it in the project.

Brian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants