So there’s a few things I want to do :
-
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*?
-
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?
My current plan is to solve both problems using the constant path feature from the pro version (although physics.raytracing2D might be faster?).
- 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
…
- 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.
- 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);