How do I use Tilemap with pathfinding

Get help using Construct 2

Post » Sun Sep 25, 2016 9:07 pm

Hi guys,

i am generating a tilemap with solid behavior at runtime. after that i put a player and enemy at random positions. the enemy got the pathfinding behavior and starts to move towards the player right after the game started. but its path is always a straight line ignoring all obstacles. therefore i added an "regenerate obstacle map" right after the tilemap was generated. unfortunatelly it changed nothing, the enemy is still ignoring the obstacles.
BUT if i put a System.wait right after the "regenerate obstacle map" it worked fine. So that means regenerating the map takes a while and not just 1 tick as statet in the manual.
So my question is: Is there an event like "On obstacle map finished"? I was not able to find it. Or maybe i am using a wrong approach, how did you handle that problem in your projects?
Posts: 15
Reputation: 232

Post » Mon Sep 26, 2016 12:19 am

Sounds like you need to have it find a path after it has regenerated its obstacle map, otherwise it will find a path before there are any obstacles (a straight line). I don't recall there being a "On obstacles regenerated" event, but you should be able to pull it off by arranging the events chronologically to make sure they happen in the right order.
Posts: 293
Reputation: 13,061

Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, marc254 and 17 guests