Gday all,
=== BACKGROUND ===
I am working on a fairly simple game; one of the core mechanics involves independent AI battles; currently this is functional however I am not using pathfinding. In the interest of keeping it simple the AI move directly to the target. The movement is done via a character controller (SimpleMove) and my own scripts for assigning waypoints, determining movement etc. (This is tied in to the AI decision cycle I have currently)
This is a top down game and will not have any real obstacles so I havent had the need for specific pathfinding as yet… The problem I have encountered though is if there are two groups of enemies converging, the front rows will fight each other with enemies to the rear just running into the back of the front row (until one dies then the gap is filled by one from behind).
=== GOAL ===
What I would like is when AI is not in the front rank to move around the outside until they can get to the enemy.
=== PLAN ===
My basic plan for how to fix this is run a test on the current combat target to see if there is room in melee range (eg. if raycasts to front, left, right and rear out to 3m all hit something then switch targets) and add in a basic obstacle avoidance mechanism… this is the main issue I am working on now.
The basic obstacle avoidance plan (fairly standard I believe) is to cast a ray directly towards the target – if there is 3m clear in front of the AI then head directly to target. If not, cast one 3m to left – if it is clear there is a temporary waypoint made at that position and the AI moves there (if it is blocked left, cast right, if blocked right, cast rear, if blocked rear, remain idle for 1.5 seconds)
The temporary waypoint was to prevent jittering in the movement (ie. alternating between moving 10cm towards the target then 10cm to the left etc)
=== QUESTION ===
What is the best way to achieve this behavior? I have looked at some pathfinding and it all seems a bit overcomplicated just to achieve what I am after (I will admit I have not looked into pathfinding theory too much however I understand the BASICS…). Is there a simple method out there to achieve this behavior? An already existing basic obstacle avoidance script/method or should I go down the route of getting a basic easy to implement pathfinding setup?
Assistance/guidance much appreciated!!!