11
\$\begingroup\$

Hi I'm creating a TD in Unity 5 and need some help with my Pathfinding.

I'm going to use Arons A* pathfinding for my AI which enables me to use dynamic objects and update the path during run-time. However in my game I want the player to be able to block the minions with special turrets which will force the minions to attack the "block tower" instead to get past to their destination.

How could I accomplish something like this?

Image for more clarity: enter image description here

\$\endgroup\$
22
+100
\$\begingroup\$

I haven't looked at specific implementation of A* by Aaron but with a normal A* you could include the 'block tower' as passable terrain but update the heuristic so that the 'cost' is much higher than a normal tile (so that AI will evaluate whether it is easier to destroy the block and continue or simple go around via the path that is not blocked).

Then you would need to update your AI so that when an enemy tries to move from a normal tile to a 'block tower tile' it automatically attacks until destroyed.

\$\endgroup\$
  • 8
    \$\begingroup\$ +1 I would add that you might want the cost of the blocking tower to be calculated depending on how long it would take X number and type of minions to destroy it, if there is any difference. A preset cost for the tower might be inaccurate if the lowest level minions take 5 seconds to destroy it but one super-minion can do it in 1 second. \$\endgroup\$ – Fuzzy Logic Aug 28 '15 at 18:05
0
\$\begingroup\$

If what you are looking for is a sort of taunting tower you can add a collider to it set as is trigger and when the minions enter the trigger they are just scripted to attack the tower.

If you want the minions to attack the towers only when there aren't alternative paths, then when the path is blocked and the A* is called to calculate another path if it returns null then you can script the enemies to find all taunting towers and target them.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.