Pathfinding enemy clipping through obstacles

Get help using Construct 2

Post » Mon Apr 29, 2013 5:25 am

Hello again! I recently went through the excellent pathfinding/line-of-sight tutorial on the site but even with having the helper sprites in place, there's one spot where the enemy will still clip through the obstacles and I can't figure out how to fix it.

If you look at the test.capx file, go through the red door so the enemy will see you, and then hide back inside the room on the right hand side. The enemy will clip through the two helper sprites and the wall sprite to get to you, but if you hide on the left side, it will go around them like it's supposed to. All suggestions for how to get around this are welcome!

Also I should mention I've tried playing around with the cell size and cell padding values with no effect on that one side.

test.capx
B
8
S
1
Posts: 34
Reputation: 938

Post » Mon Apr 29, 2013 6:12 am

the pathfinding nodes are positioned at the top left of the cells.. so the enemy will navigate on the lines rather than the gaps.
one solution could be nudging everything in the layout up and to the left 16 pixels.. then it will look like thee nodes are positioned in the centre of cells on your tiled background.
i set the cell size to 32 aswell and it seems to be go through the door ok without clipping.

i dont often use pathfinding though, so there's probably a better way to fix this. without having your whole layout constantly offset
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Mon Apr 29, 2013 7:40 am

Thanks Keepee. I'll try changing the cell size and see if that makes a difference.
B
8
S
1
Posts: 34
Reputation: 938

Post » Mon Apr 29, 2013 7:48 am

I've gotten better results with using a cell size of 28.. with 32 the enemies wouldn't go through the doorway at all... but i'm still having some issues on some of the other doorways where the enemies won't come through the doorways now. I'm wondering if it would be better to just have the obstacles set to anything solid instead of using the custom obstacles with the helper tiles.
B
8
S
1
Posts: 34
Reputation: 938


Return to How do I....?

Who is online

Users browsing this forum: Khamsou, nedzad and 13 guests