I’m attempting to implement a top-down Zelda-like enemy motion system. Take into account a display of x tiles vast by y tiles tall, every tile being 16×16 pixels.
I’m not asking for code right here. I’m asking for course. I’m utilizing Godot, however maybe the reply isn’t engine particular. Ought to I exploit one thing akin to NavigationAgent2D? Or handbook motion? Primarily based on the necessities under what’s the finest follow for an enemy motion system?
Necessities:
- Enemies can solely transfer in cardinal instructions (up, down, left proper).
- Enemies can’t enter tiles which have physics colliders.
- Enemies are confined to the present display and should not depart the display.
- Enemies could or could not move by way of one another (based mostly on enemy kind).
- Enemies could or might not be inclined to maneuver towards the participant (based mostly on enemy kind). Even when they transfer towards the participant, they need to nonetheless respect cardinal course motion.
- Enemies may be hit with melee or ranged weapons which apply a pressure to them. The pressure ought to apply to them if hit from the identical or other way that they’re shifting.
Most tutorials simply have pathfinding the place enemies take the shortest path to the participant. However I need my enemies to maneuver across the display in confined cardinal instructions and be principally oblivious to the the participant, like in Zelda. However I maintain operating into issues the place they get caught or don’t maintain their motion aligned with the tile grid.
As I see it, enemies resolve a course to maneuver and what number of tiles to maneuver, after which once they attain their vacation spot tile they need to resolve once more. However I could possibly be going about this fallacious. Different enemies (or the participant) may get in the best way and so they’d be compelled to recalculate their subsequent transfer. It’s vital that they keep aligned with the grid.
Is there some built-in node or system in Godot that can be utilized to fulfill these necessities?
Any solutions are really appreciated.


