Eonirr

Untitled

Oct 23rd, 2026
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. void ComputePush(){
  2. push = Vector3.zero; Vector3 pos = transform.position; float minSqr = minDistance * minDistance; float blockSqr = attackBlockDistance * attackBlockDistance; bool tooClose = false;
  3. foreach (var other in all){
  4. if (other == this || other.enemy.enemyIsDead) continue;
  5. Vector3 away = pos - other.transform.position; away.y = 0f; float sqr = away.sqrMagnitude;
  6. if (sqr < blockSqr) tooClose = true;
  7. if (sqr >= minSqr) continue;
  8. float dist = Mathf.Sqrt(sqr);
  9. away = dist < 0.01f ? Quaternion.Euler(0f, Random.value * 360f, 0f) * Vector3.forward : away / dist;
  10. push += away * (minDistance - dist) * pushSpeed;
  11. }
  12. if (!tooClose) { crowdedTime = 0f; crowded.Remove(enemy); return; }
  13. crowdedTime += checkInterval;
  14. if (crowdedTime < maxAttackDelay) crowded.Add(enemy); else crowded.Remove(enemy);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment