They don’t manage to go through the walls (so I think the obstacle layer is properly configured) but they start moving there and then go back again lol.
My Pathfinding.cs
file seems to be identical to Hugo’s. What could be the issue here?
They don’t manage to go through the walls (so I think the obstacle layer is properly configured) but they start moving there and then go back again lol.
My Pathfinding.cs
file seems to be identical to Hugo’s. What could be the issue here?
If I recall correctly (and I could be wrong, I’d have to go back and refresh my memory) this is normal. The position they move to is the best position they can find because they have a limited range. Moving towards a doorway so that they can eventually go around and get to the enemy is not the best move because it leaves them further from the target. They don’t have a concept of a multi-turn move, so the best move is to get within shooting range of the player units, regardless of the wall being in the way.
What you say makes perfect sense. However, I still don’t understand why my AI is doing this:
Whereas, in the course lecture, you see the enemy going around the corner to get closer to the units:
Perhaps turn your PathfindingGridDebugObject
's on and let’s look at the values. Perhaps it will reveal something
The issue was on my ShootAction.cs
. I somehow missed updating the code properly, and was doing
var validGridPositionList = new List<GridPosition>();
var unitGridPosition = unit.GetGridPosition();
… instead of using the GridPosition unitGridPosition
received in the parameters.
Thank you @bixarrio for your help
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.