Pathfinding

Get help using Construct 2

Post » Wed May 20, 2015 1:24 am

How do I get a sprite, using the Pathfinding behavior, to -

1.) Check the next single cell of its path for obstacles, (cell of the A* grid).
(The very next cell mind you, cant afford to regenerate the whole path every time it scans for an obstacle.)

2.) Choose between moving into the cell (if the cell is not obstructed)
OR performing an alternative action (if the cell is obstructed).

3.) Repeat.
B
3
Posts: 6
Reputation: 187

Post » Wed May 20, 2015 5:21 am

1. you can't
2. you can't
3. ok

1 - you can't check nodes where something will move. when you regenerate map for movement it creates nodes on the map. and when you use find path it uses nodes that go closest to your target x,y
2 - if you don't have collisions on that object and is not an obstacle then your sprite will move through it, else it will already go around it
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
41
S
14
G
12
Posts: 623
Reputation: 9,359

Post » Wed May 20, 2015 7:29 am

1 - Why? What happens to the grid during all of this?

2 - The built in collisions when misused as a workaround for bad pathfinding not only eat your processor alive, they do not yield reliable or useful results.
B
3
Posts: 6
Reputation: 187

Post » Wed May 20, 2015 6:14 pm

Let me ask a different question -

How do you determine what cell that an object using the pathfinding behavior will move through next? (cell coordinates not layout coordinates)
B
3
Posts: 6
Reputation: 187

Post » Wed May 20, 2015 7:41 pm

You have the option to check whether a Cell is an obstacle or not using the path finding. So you could use that for checking.
You also have the option to regenerate obstacle map around certain objects, might be useful as well.

The cell size is based on the settings in the path finding. So if cell size is set to 30 each cell will be 30x30 pixel so you could use this information to make a functionality to check cells around the object.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Thu May 21, 2015 6:31 am

"You have the option to check whether a Cell is an obstacle or not using the path finding. So you could use that for checking."


Yes, this is my point exactly. So how do you do it?

"The cell size is based on the settings in the path finding. So if cell size is set to 30 each cell will be 30x30 pixel so you could use this information to make a functionality to check cells around the object. "


How?
B
3
Posts: 6
Reputation: 187



Return to How do I....?

Who is online

Users browsing this forum: sublimate and 2 guests