Yes, flocking is the correct word.
No, this is a RTS game. The velocity of each entities doesn't change, i just need to avoid stuck situation.
Here my logic: the unit setup has 3 raycast sensors. If at least one of them collide another unit, something must be done (wait or take priority).
Case 1 = if unit 2 detect an ally which go front of it, unit 1 must "shift" to another direction for the following cell and take back the path normally.
Case 2 = if an ally goes to the same direction of the unit, someone must take priority and the other must stop.
Case 3 = if an unit collide an ally and it is in front of it, wait, event if his id is higher.

In practice:
func checkCol(rayVar):
# srcScript = the unit who detect another one
var rayDirect = rayVar.get_collider().get_parent()
if rayDirect.UnitPath.empty() == false and srcScript.id < rayDirect.id and\
srcScript.UnitPath[srcScript.step] == rayDirect.UnitPath[rayDirect.step] or\
rayDirect.modeConstruction:
srcScript.delayPushNeigbor.start(0.5)
srcScript.set_physics_process(false)
if srcScript.rayPushDir.is_colliding():
var rayDirect = srcScript.rayPushDir.get_collider().get_parent()
if rayDirect.UnitPath.empty():
else:
if rayDirect.modeConstruction:
srcScript.delayPushNeigbor.start(0.5)
srcScript.set_physics_process(false)
elif srcScript.id < rayDirect.id:
var dirDict = {'horizontal':Vector2(1, 0),
'vertical':Vector2(0, 1),
'diagonal':Vector2(1, 1)
}
var normOldangle = srcScript.oldAngle.normalized().round()
var normOldangleUnit = rayDirect.oldAngle.normalized().round()
if normOldangle == dirDict['horizontal'] and normOldangleUnit == -dirDict['horizontal'] or\
normOldangle == -dirDict['horizontal'] and normOldangleUnit == dirDict['horizontal']:
modDirection(dirDict['vertical'])
elif normOldangle == -dirDict['vertical'] and normOldangleUnit == dirDict['vertical'] or\
normOldangle == dirDict['vertical'] and normOldangleUnit == dirDict['vertical'] or\
normOldangle == dirDict['diagonal'] and normOldangleUnit == -dirDict['diagonal'] or\
normOldangle == -dirDict['diagonal'] and normOldangleUnit == dirDict['diagonal'] or\
normOldangle == Vector2(1, -1) and normOldangleUnit == Vector2(-1, 1) or\
normOldangle == Vector2(-1, 1) and normOldangleUnit == Vector2(1, -1):
modDirection(dirDict['horizontal'])
elif not srcScript.modeConstruction:
srcScript.delayPushNeigbor.start(0.5)
srcScript.set_physics_process(false)
else:
srcScript.delayPushNeigbor.start(0.5)
srcScript.set_physics_process(false)
elif rayL.is_colliding():
checkCol(rayL)
elif rayR.is_colliding():
checkCol(rayR)
And here the code when the unit stopped waiting end:
if rayPushDir.is_colliding():
var rayDirect = rayPushDir.get_collider().get_parent()
if rayDirect.UnitPath.empty():
rayDirect.physxProc.pushAway(rayDirect) # physxProc = another script which containt condition code upper
elif rayDirect.is_processing():
delayPushNeigbor.stop()
configFrame() # orient vehicle then advance
else:
if rayPushDirL.is_colliding():
var rayDirect = rayPushDirL.get_collider().get_parent()
if rayDirect.id < id or rayDirect.UnitPath.empty():
delayPushNeigbor.stop()
configFrame()
elif rayDirect.id > id and not rayDirect.is_processing():
delayPushNeigbor.stop()
configFrame()
elif rayPushDirR.is_colliding():
var rayDirect = rayPushDirR.get_collider().get_parent()
if rayDirect.id < id or rayDirect.UnitPath.empty():
delayPushNeigbor.stop()
configFrame()
elif rayDirect.id > id and not rayDirect.is_processing():
delayPushNeigbor.stop()
configFrame()
else:
delayPushNeigbor.stop()
configFrame()