almost 2 years ago - Shurenai - Direct link
Originally posted by Midas:
Originally posted by Marmarmar34: I'm fine with the concept of an undead corpse either shambling or scrambling unpredictably towards you, but the pathing itself is the issue that I have. Like if L4D zombies pathed towards you like this game's zombies did, it would be pretty miserable.

It's weird because the zombies CAN move diagonally towards you, it's just sometimes they don't. Like the pathing algorithm isn't telling them to always prioritize diagonal paths (even though they should, because it gets them there faster).
Outside of a certain range, the AI paths in direct lines along the N/E/S/W directions; Once they're within that certain range, they take the most direct path they can to the player. I think that certain range is around 8-10 blocks.

The reason for this is simple- Performance overhead. It costs a lot for the AI to determine what the most direct path is, and the larger the area it covers the more expensive that action is. So, the AI uses simplified movement to get 'close enough' at which point the performance costs of the more refined movement pathing is minimized.

In short, To US it seems like the most obvious, fastest, and most efficient path is a straight diagonal line. But to the CPU, not so much.