Need help regarding an AI problem
Posted: Sat Mar 02, 2013 6:36 am
I have been trying to help a friend with a problem in his map, and after several unsuccessful attempts I felt I should ask you. The problem is where when a unit (the computer's hero in this case) is told to attack a player's hero, and there are towers in the way of the shortest route to the player's hero, instead of the computer's hero running to the towers and attacking them, he simply sees them as a wall and tries to find another way around. Do you think you would be able to fix this so the computer's hero just simply attacks the towers and then runs to the player's hero?
My idea was to have a trigger constantly check offsets in front of the computer's hero to detect whether there is a building closely in front of it or not, and if so, enable collision and force the hero to attack it, and if there is no building within a close range in front of him, it would disable collision, allowing the computer's hero to follow a hero even if there is a building in the way, and then of course, when that building is detected, collision would be re-added and the hero would be forced to attack it.
The above method, the way I made it anyways, seems to sometimes work, and other times not. It mainly works when the computer's hero is pretty close to you when it tries to attack you. Also, for some reason, I notice that sometimes when the collision for the computer's hero is off, it will let him walk through the buildings (like it should, so that it's able to click through it and walk to it), but other times it acts as if the building is a wall and doesn't bother to try walking through it.
Sorry if this seems extremely redundant, I'm just trying to give you a good overview of the situation and since it's 6 A.M., I'm far too tired to re-read and edit it right now.
Here is my friend's map that includes the solution I was working on, so you can look at that if you want to. I would recommend testing it on RoC, as the few times that I tried it on TFT the computer's hero didn't seem to want to even attack me, whereas on RoC it was normal.
P.S. I'm really tired. Good night.
-Eq
My idea was to have a trigger constantly check offsets in front of the computer's hero to detect whether there is a building closely in front of it or not, and if so, enable collision and force the hero to attack it, and if there is no building within a close range in front of him, it would disable collision, allowing the computer's hero to follow a hero even if there is a building in the way, and then of course, when that building is detected, collision would be re-added and the hero would be forced to attack it.
The above method, the way I made it anyways, seems to sometimes work, and other times not. It mainly works when the computer's hero is pretty close to you when it tries to attack you. Also, for some reason, I notice that sometimes when the collision for the computer's hero is off, it will let him walk through the buildings (like it should, so that it's able to click through it and walk to it), but other times it acts as if the building is a wall and doesn't bother to try walking through it.
Sorry if this seems extremely redundant, I'm just trying to give you a good overview of the situation and since it's 6 A.M., I'm far too tired to re-read and edit it right now.
Here is my friend's map that includes the solution I was working on, so you can look at that if you want to. I would recommend testing it on RoC, as the few times that I tried it on TFT the computer's hero didn't seem to want to even attack me, whereas on RoC it was normal.
P.S. I'm really tired. Good night.
-Eq