0

so I have a kind of problem I brought on myself...
I have a tile grid where a tank can move via A* calculations. But to optimize the number of nodes I used Bresenham's line of sight and so I have smooth movement between nodes and avoid the ladder effect.
But now I want to avoid obsctacles in the way in the form of other tanks, soldiers, etc. What I did was have two raycasts one each tank "shoulders" to scan ahead and if something unexpected blocks the path, quickly find an alternative in the adjacent tiles.
For example if I come from 1,1 to 5,5 and a tank is blocking on 3,3 what I want is on nodes 2,2 3,2 4,3 and 4,4 create new A* nodes so in effect my tank sidesteps the other tank and continues towards 5,5 again. So what I need in a formula that allows me to map those lateral tiles from whichever direction I come. In the example above I start from 1,1 but the new nodes would be different if I come from 1,3 to 5,3 and find the tank in 3,3 : could be 2,3 3,4 and 4,3

Examples here: https://i.stack.imgur.com/b4Hdm.jpg

How can I accomplish this? Thanks

Corta
  • 1
  • What if the other tank moves as well? Imagine both tanks moving exactly towards each other you might being calculating a path to avoid each other which every step needs to be updated since both already avoided the other .. you might never finish ^^ – derHugo Oct 02 '22 at 10:04

0 Answers0