how to prevent closing the path of the pathfinder

0 favourites
  • 7 posts
From the Asset Store
Antisuspend Plugin for Construct 3 prevents the runtime from getting suspended.
  • Hi guys , I'm making a tower defense game where you can put the towers whereever you want and the enemies find their path to the base using the pathfinder , the only issue that you can close the path with the towers and the enemies stop moving , does anyone encountered this problem before ? please give me a solution or a way to make it work , thanks.   <font face="Arial, Helvetica, sans-serif"></font><font size="2"></font>

  • You'll have to make some way to prevent the player from blocking the path. If there isn't a path to move along, your enemies wont be able to find a path.

  • In most free-pathing TDs, the mobs attack the towers if they can't find a path through to the end. Usually, to prevent this being abused by the player to buy more time, those attacks are pretty brutal, and can wipe out a tower in a single attack.

    To program this, I'd imagine something simple like, if the mobs can't find a path to the exit, find a path to the nearest tower and start pummelling it. Once it's destroyed, try find the exit path again, and so on until the player feels like an idiot for trying to screw your game :P

    The other option is to prevent the player from putting down a blocking tower at all. In this case, just before you actually place down the tower (once it's been verified for position, cost, etc.), run a pathfinding action to see if a path is possible once the tower would be theoretically placed down. If it's not possible, prevent the tower from being placed.

  • scirra.com/forum/how-to-prevent-closing-the-path-of-the-pathfinder_topic74474_post445894.html

    My Question

    I'm making a tower defense game where you can put the towers whereever you want and the enemies find their path to the base using the pathfinder , the only issue that you can close the path with the towers and the enemies stop moving , does anyone encountered this problem before ? please give me a solution or a way to make it work , thank

    You Suggested

    The other option is to prevent the player from putting down a blocking tower at all. In this case, just before you actually place down the tower (once it's been verified for position, cost, etc.), run a pathfinding action to see if a path is possible once the tower would be theoretically placed down. If it's not possible, prevent the tower from being placed.

    My Reply

    That doesn't seem to work because you now get two pathfinders working at the same time. and Because you need to refresh the obstacle map before you find the path , now the obstacle map updates obstacles for the first pathfinder and the second pathfinder updates other obstacles and it ends up not working at all

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I too am looking for a solution to this problem.

    The other option is to prevent the player from putting down a blocking tower at all. In this case, just before you actually place down the tower (once it's been verified for position, cost, etc.), run a pathfinding action to see if a path is possible once the tower would be theoretically placed down. If it's not possible, prevent the tower from being placed.

    GeometriX, can you offer a suggestion as to how to solve the problem the way you suggested? How do you place a theoretical tower so that you can run the pathfinding test on it, without actually laying down the tower?

  • Wait, I figured it out. I just set a global variable to capture the UID of the most recent tower placed.

    Then I set up an event that, on Pathfinding failed to find path, pick the instance of the tower with the UID stored in the variable and destroy it.

    Then have your creeps find the path again.

  • This method actually doesn't work very well, heh. Any other suggestions?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)