Hello everyone, I’m new to AI path finding in general and had a question on which (if any) of the following approaches might be best for my situation:
My Situation:
I’ve got some NPC boats that know where the player’s boat is located. I would like to have the NPC boat(s) move to the player’s position plus/minus an offset amount (essentially the NPC boat’s “ideal engagement range” (a min/max distance the ship prefers if at all possible).
What I’ve got right now:
I’m giving the NPC boat(s) the players position, then using Unity’s Nav Mesh system to actually find a path to that position. I’d like to keep the Nav Mesh system for the course plotting, and just worry about how the initial point of interest is determined if possible.
My ideas:
- Parent - Child Node System:
-When the point is determined, go through all of the highest level parents to check for min/max distance and line of sight, take all possible matches then go into children and make more checks (and so on for each level of child).
-I can see it working but it just seems like a lot of unnecessary checking, and it requires lots of high level parents to make sure that good locations are not passed on because the parent does not have LOS on the target.
- Get Local Nodes:
-When the point is chosen, check for all Nodes in an area and choose between those.
-Simple, but possible issues with getComponent having to get lots of scripts in an area depending on density of Nodes.
- Nodes with Trigger Boxes:
-Similar to 2, but here, when Nodes detect collision, they send their script to the colliding object, which would then send that as a array/list to the script that handles choosing a position.
-Similar possible drawback to 2.
- Raycasting:
- When the point is chosen, make a raycast from that point in some direction, checking that the end point of the raycast is greater than the min distance. If it is, then choose a point from the min/max distance along the ray and make that the new adjusted target. If there is no good point, rotate a certain amount and try again until a good point is found.
-Would avoid Nodes all together, would need additional logic to make sure the raycast does not put locations too close to other geometry (nodes could avoid this by checking the area around them when created and removing themselves if that are too close to something).
Any ideas are appreciated, thank you for reading.