A* Pathfinding Project

How to path to a clamped parameter?


#1

Working on a 2.5d army combat game similar to Dragon Force for the Sega Saturn. The 2d sprites move around on a 3d plane and smack each other via AI. I’m using A* for the units to target each other but I’m having difficulty making them stand next to the person they’re attacking.

Essentially I need to make sure a unit is standing to the left or right (not directly above or below) their target and is within +/- 0.2 the z-position of the target before they initiate their attack animation. Until recently I was using visual scripting tools so I’m pretty nooby when it comes to C#.

I’m just using the basic AIPath script right now but can see how it could probably be extended. Specifically by adding an option to the “When Close to Destination” field? Just a thought?

I tried to do my due diligence in looking at this forum before asking and didn’t find anything but feel free to point me in the direction of another post or provide any kind of guidance at all. Thanks in advance!


#2

Hey,

Sorry for the late reply.
I would just custom set the destination to +/-0.2 from the target, rather than the target itself.


#3

Oh, good point. But how would I go about making sure they’re to the right or the left and not above/below? Guess I could clamp their x as well but there’s a lot of situations where units will get knocked around and have to recalculate.

Anyway, it sounds like there’s not some switch I can flip to make this happen - it just has to be custom coded and that’s exactly the answer I was looking for. Thank you!