Best solution for navigating maze w/ destructible walls

I’m making a 3d pengo clone. For those who don’t remember the game, it’s basically a maze with enemies, where the blocks can be moved by the player and destroyed by both the player OR the enemy Clearly, I can mark the walls as obstacles,make em dynamic so the grid updates as walls get moved and destroyed, and get the enemy to avoid them just fine, as long as I don’t mind that enemies can’t destroy walls. I’ve also gotten it to if i don’t bake in any obstacles, it just takes the shortest path, stopping to destroy walls along the way. What I want is for both. When the time it takes to go around is faster, it goes around, when it’s faster to go thru, it goes thru. The other option being it goes around until it gets within a certain distance, it starts going straight for the player. What is the best solution to do this? My thoughts so far:

  1. Two grid graphs, one for when you are far away, one got when you are close.Is there a way to switch whgich graph the enemy is using?
  2. The walls not necessarily being obstacles, but change the cost of crossing that space. That way it would still tend to avoid walls, unless it made sense to go thru.
  3. Scrap using this, roll my own method. I know I could do it w a lot of work, but I am not a fan of reinventing the wheel if I don’t have to

So, a little direction would be nice. Is one of the solutions viable If so, how, or is there a better way? Just started playing with this and I gotta say so far, awesome.

Hi

I think you should check out tags: https://arongranberg.com/astar/docs/tags.php
I would recommend setting a tag on the walls, and then on the Seeker component you can specify the cost of traversing the walls with tiles on them. A penalty of 1000 is roughly equivalent to the cost of moving a distance of one world unit.

Perfect. Ya this is headed me down the right path

1 Like