Pathfinding not quite working

Get help using Construct 2

Post » Fri Mar 15, 2013 1:29 am

I've been experimenting with the pathfinding behaviour, and I'm quite impressed with it so far. One hiccup, though, is that it doesn't quite work when you place more obstacles while objects are still moving along a path.
I've set it so they stop moving, regenerate the obstacle map, and try to find another path, but generally several of them will keep moving along the old path, ignoring obstacles that should stop them.
I assume this is because the behaviour generates the paths and obstacle maps in the background, but is there a workaround to make sure that the objects don't check for a path until they have the most up-to-date obstacle map?
Also, I know that regularly refreshing the obstacle map is a bad idea, but I've limited the layout to only 20x20 cells to try and offset any performance issues.
B
62
S
26
G
12
Posts: 122
Reputation: 11,330

Post » Fri Mar 15, 2013 1:37 am

I also have this issue with my space game, as I've seen enemy ships fly into asteroids and blow up even though they are updating their paths every second and should be going around.Excal2013-03-15 04:09:09
Project Lead of Zems Online Card Game

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

Post » Fri Mar 15, 2013 6:14 am

You could use a triggered event when another obstacle enters the view. In your object placement event have a sub event check for pathfinding objects within a specified radius ("find nearest/farthest" or conditional "distance(obstacle.x,obstacle.y,pathfinder.x,pathfinder.y) <= specified radius" ), then the action could be "Object>Pathfinding:Movement>Stop". This will (should!) stop any specified objects currently running along a path to become halted. Good luck!

Paul
B
17
S
5
G
4
Posts: 24
Reputation: 4,039

Post » Fri Mar 15, 2013 6:40 am

Well, the problem seems to be that even after they stop, they will start again after a fraction of a second, still on the wrong path.
@Ashley, does the Regenerate Obstacle Map action have a similar time delay to the Find Path action, or should a Find Path action placed shortly after the regenerate action use the new obstacle map?
B
62
S
26
G
12
Posts: 122
Reputation: 11,330

Post » Fri Mar 15, 2013 10:16 pm

Sorry for double post, but I seem to have a cheap workaround for the time being. If I use a 'wait' action for a quarter of a second, they seem to do things as they should. I assume, however, that on slower computers that wouldn't be enough time to regenerate the obstacle map so if anyone has a better solution it would be much appreciated!
B
62
S
26
G
12
Posts: 122
Reputation: 11,330

Post » Sat Mar 16, 2013 12:56 am

I agree, it would be nice to have a response from a developer on exactly how this behavior works.

The more I mess around with C2, the more I realize I have to account for optimization. A lot of the behaviors are absolutely excellent in general, but in making the game look smooth there is a lot of work still to be done. For example, I basically had to manually implement collision using CustomMovement in addition to using the Physics library in order to make my collisions feel somewhat realistic.
Project Lead of Zems Online Card Game

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

Post » Sat Mar 16, 2013 11:59 am

Personal opinion: I wouldn't use pathfinding at all in the sort of situations it sounds like you're describing. Pathfinding is a strategic planning activity that should be done infrequently to plan high-level movement. As you've discovered, it's expensive and time-consuming.

Collision avoidance is a low-level, localised movement activity, which is best solved by a reactive steering behaviour such as described at http://www.red3d.com/cwr/steer/Obstacle.htmltanoshimi2013-03-16 11:59:45
B
8
S
2
G
3
Posts: 83
Reputation: 2,668

Post » Wed Aug 07, 2013 9:45 pm

thats pretty cool.. is there a .capx for something like this? i would love to see how it works in c2
B
6
Posts: 20
Reputation: 904


Return to How do I....?

Who is online

Users browsing this forum: armaldio, blackhornet, ETgirl79, TiagoCesar and 16 guests