I want the enemies to follow my player when attacking, but I don’t want them crowd over the player, so I’m trying to think a way that would make the enemy stay in position around my player, in situations where the player would stay still. The goal is to have multiple enemies attacking the player but each one positioned accordingly with the pads. This whole structure around the player is a game object that follows the player.
When the enemy notices the player, it will run in his direction
When getting close, it will hit one of the two collider zones represented by the orange boxes on each side. Each collider zone has 5 positioning pads.
When inside a collider zone, it will then see the pads, then select the first one and follow it’s position until it dies, kill the player, or the player gets too far for too long.
This kind of formation would only be noticeable if the player stand still. If the player is running, the enemy will just follow one of the the zones to get a position.
I came up with this to solve a problem which was causing the enemies to crowd over the player / the zone that prevents them to pass throught the player:
And to finish, these are the results I want to avoid ///// and the results I would like to achieve:
Your drawings are AWESOME! Your drawings makes it easy to conceive the problem visually.
Positioning pads is interesting, but feels maybe too specific.
How about just combining your current “stay at a radius” script but adding also a heuristic to try and be away from other enemies to some extent?
It would be tricky to get the prioritization on those two right… when you’re far, you want to just run at the player… but as you get close to the “standoff range” around the player you want to change to look for potential other positions that are the furthest possible from everyone else.
You could have a ring of positions around the player and a manager that hands out positions that are farthest from other enemies… and then periodically the enemies might even re-ask the manager “hey, is there any less crowded place I can stand?” just to keep it all sorta… levelling out over time…
When an enemy selects a position, you may want to have a special object that keeps track of all of the available positions and whether they have been assigned already. That way you don’t have two enemies selecting the same spot.
You could give that object a method to return the next available spot and then each enemy can call that method.
Thanks for the tips everyone. Right now I’m building something like this:
All the pads are inside CombatRings gameobject, which lists all of them gameobjs
Each pad as a int group and bool available = true
The order is defined by shortest to farthest, and available true means that no enemy is following the specific pad.
When the enemy gets a certain distance from the player (can be a colliding zone) a function will be triggered
The function will iterate through the available pads
Then list the 10 pads nearest to the enemy (because I want at least 1 pad from each of the 5 groups to be in the list)
From the 10 nearest available pads, get the only the ones from the lowest group num
From the lowest group number pads, pick the closes one to be the agent destination.
And this way, the enemy will always pick the closest pad, giving priority to the best positioned ones.
My only wondering is if this will cost too much performance, it looks like a lot of lists and comparisons everytime an enemy enters attack mode