how to prevent closing the path of the pathfinder

Get help using Construct 2

Post » Sat Aug 17, 2013 2:32 am

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.   
B
24
S
3
G
1
Posts: 67
Reputation: 2,946

Post » Sat Aug 17, 2013 5:29 am

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.EncryptedCow2013-08-17 05:30:18
B
46
S
14
G
7
Posts: 603
Reputation: 8,096

Post » Sat Aug 17, 2013 9:11 am

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.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Fri Aug 23, 2013 7:31 am

http://www.scirra.com/forum/how-to-prevent-closing-the-path-of-the-pathfinder_topic74474_post445894.html?KW=#445894


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
B
24
S
3
G
1
Posts: 67
Reputation: 2,946

Post » Sun Jan 03, 2016 5:30 am

I too am looking for a solution to this problem.

GeometriX wrote: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?
B
9
S
1
Posts: 33
Reputation: 612

Post » Sun Jan 03, 2016 5:55 am

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.
B
9
S
1
Posts: 33
Reputation: 612

Post » Sun Jan 03, 2016 5:39 pm

This method actually doesn't work very well, heh. Any other suggestions?
B
9
S
1
Posts: 33
Reputation: 612


Return to How do I....?

Who is online

Users browsing this forum: SturmIV and 10 guests