Hello everyone,
I’ve been working on a retro 2D isometric game. I’ve encountered a particular challenge and I’m hoping to get some insights from the community.
Goal: I want my character to always move in a zigzag pattern across the grid. For instance, if the character needs to move from the bottom left of the grid to the mid top, instead of taking a direct path, it should move diagonally to top right until it gets to mid, then zigzag every tile until reaching the destination.
Demonstration: python-0-Gn6-Vd7-Ns-E hosted at ImgBB — ImgBB
Current Setup: I have successfully integrated the A* Pathfinding Project and am currently using the AILerp
component for movement. The character can move towards the clicked point, but the path is typically a direct line or changes directions randomly.
Challenges:
- Enforcing a consistent zigzag pattern regardless of the start and end points. Currently it is random and when it does a zigzag it takes 2 tiles at a time to change direction.
- Ensuring the zigzag path doesn’t inadvertently lead the character into obstacles or unwalkable areas.
I did consider post-processing the path after it’s calculated to enforce a zigzag pattern, but I’m concerned about potential issues with unwalkable areas or obstacles.
Has anyone here tackled a similar challenge or have suggestions on how best to approach this? Any help, tips, or references would be greatly appreciated!
Thank you in advance!