- Home /
A* pathfinding for dynamic obstacles and player made blockages?
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 runtime. 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:
I would recommend to code your own A* pathfinding, in a grid system like yours it's super easy.
What you want to do is in your "WalkToDestination()" to add something like "if(next_tile[x,y] == TurretVal){attackTurret();}"
So add something in your movement system, before the next node is called. So basically: if you use a while-loop when your position != node.position it will keep trying to get there, add a check (if-statement) to check if there is a turret in your way, if it's true attack it.
EDIT: Also remember to call the pathfinding algorithm every time the players does something (puts down a building).
Your answer
Follow this Question
Related Questions
Patfinding cant change destination Target 0 Answers
Adding Wander option to AI 1 Answer
How can i avoid the enemy to sight me through walls? 1 Answer
Coroutines randomly stop working 0 Answers
Distribute terrain in zones 3 Answers