How often should I search for path to a mobile target ?

Just started using Construct 2? Post your questions here

Post » Wed Feb 11, 2015 11:49 am

Hi. This question is about the pathfinding behavior, which I think uses a lot of CPU.

If my pathfinder is looking for a mobile target (for example the player), how often should I update its path ? Every tick ? Every 0.X seconds ?
I also have the same question when having a lot of enemies (30+) looking for the player. :)
B
12
S
7
G
7
Posts: 448
Reputation: 4,272

Post » Thu Feb 12, 2015 2:10 pm

One suggestion would be that each tick only one enemy updates path.

You can create variable "currentEnemy", every tick add 1 to it, when it is > number of enemies set it to 0.
And then each tick
System.pick nth instance (select enemy and "currentEnemy" as instance number) - update path.

That way each tick only one enemy will look for path and your CPU will be used evenly.
Of course, that mean less enemies = better pathfinding.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest