Most optimal pathfinding update speed?

Get help using Construct 2

Post » Thu Apr 18, 2013 2:29 am

Any tips for optimizing pathfinding events so you're not draining the CPU?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Thu Apr 18, 2013 6:01 am

I've been using an Every X seconds Event while my characters chase another character. This allows the Find path and Move along path Actions to do their thing and not hamper the other, since it takes a short time to calculate the path.

I've also set up actions to enable/disable the Pathfinding behavior...I'm not entirely sure if this works well, or at all, but it might be worth testing.

I've also been advised to employ the Trigger Once Event to prevent successive calls on the Find path Event from triggering too soon, cancelling out Move along path because it's still calculating. You might want to try that.

I'm also personally curious about how long a single call on Find path takes on average to calculate. I know it's dependent upon the distance and number of obstacles, etc, but what's a good mean time?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
112
S
20
G
8
Posts: 741
Reputation: 13,636

Post » Thu Apr 18, 2013 6:17 am

Your guess is as good as mine.

From my testing, pathfinding is more or less inconsistent due to CPU issues. I can tell because when my enemy ships are pathfinding, a yellow afterburner sprite appears behind their engines. When they are moving due to bullet behavior (the default behavior I gave them), this sprite does not appear.

I am currently having them 'pathfind' every 1 second, but I'm not sure that is optimal. I'm thinking of removing pathfinding altogether and giving them a set AI behavior, in particular the rotate-move-rotate-fire behavior I am trying to set up that I didn't get many responses on.

I am starting to think that pathfinding by itself is not really a good behavior to use, but instead to be integrated as a small part of an object's behavior for solving the problem of how to get from position A to position B.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194


Return to How do I....?

Who is online

Users browsing this forum: gregorysforster, Matthew de and 1 guest