Help with two problems - maybe a need to buy the pro version?

So there’s a few things I want to do :

  1. I want a flee behavior that takes in multiple enemies and flees from them both simultaneously. Is it possible / already written into aron’s a*?

  2. I want a “go to this enemy but keep a constant distance” function.

Are either of these already written into the pro version, or is this just something I need to do myself?

Hi

  1. Sorry, this is not possible in any version. It might be possible to write a custom path type, but it is definitely not built-in.
  2. This can be accomplished, though not out of the box. You would need a custom path ending condition: see https://arongranberg.com/astar/docs/pathendingcondition.html

My current plan is to solve both problems using the constant path feature from the pro version (although physics.raytracing2D might be faster?).

  1. My flee doesn’t need to be a global flee, it can be fully localized.
  • Run the constant path on my fleeing object
  • Gather all nodes at the maximum distance from the center (+/- some number of nodes for tolerance)
  • Draw a polygon using the center of these nodes as points
  • Run the constant path on my objects to flee
  • Gather all nodes at the maximum distance from the center (+/- some number of nodes for tolerance)
  • Draw a polygon using the center of these nodes as points
  • Find the intersections between the fleeing objects polygon and the objects to flee polygons
  • Record each angle of intersection, and look for the largest gap in angles.
  • Go back to the fleeing objects nodes, and pick the one which matches closest to the center of largest angle

  1. Yeah I might be able to do this one on my own no problem. It seems like a much simpler fix - I’m just not sure which is the most efficient. Will rewriting the pathendingcondition effect just the ai_path I made for that object, or will it overwrite everything? That seems a bit wrong to me

As for 1. That seems very complex. I would advise against any kind of computational geometry, it will only bring you headaches.

  1. The path ending condition is set per-path. It’s not global.
    So to use it you will need to take control over the path calculation in the AIPath script. You can do this using e.g.
// Disable the built-in path recalculation
ai.canSearch = false;
// Create a path object
var path = XPath.Construct(...);
// Send it to the ai, which will calculate the path and follow it
ai.SetPath(path);