private void Flee(List objectsToFlee)
{
Vector3 fleeVector = Vector3.zero;
foreach (GameObject obj in objectsToFlee)
fleeVector += (obj.transform.position + other obj that are in range.transform.position) / number of obj in range
}
Movetwards(- fleeVector);
}
anyone know how to say this? like how could i say all obj in range with more mass than this gameobject added together then divided by the number of those gameobjects. Im making an Ai and I want it to run away from any gameobject with more mass than itself. its not that hard to make it run away if one enemy comes in range, but if 2 or more enemies come in range, i need it to find the best way to run away