Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ComputePush(){
- push = Vector3.zero; Vector3 pos = transform.position; float minSqr = minDistance * minDistance; float blockSqr = attackBlockDistance * attackBlockDistance; bool tooClose = false;
- foreach (var other in all){
- if (other == this || other.enemy.enemyIsDead) continue;
- Vector3 away = pos - other.transform.position; away.y = 0f; float sqr = away.sqrMagnitude;
- if (sqr < blockSqr) tooClose = true;
- if (sqr >= minSqr) continue;
- float dist = Mathf.Sqrt(sqr);
- away = dist < 0.01f ? Quaternion.Euler(0f, Random.value * 360f, 0f) * Vector3.forward : away / dist;
- push += away * (minDistance - dist) * pushSpeed;
- }
- if (!tooClose) { crowdedTime = 0f; crowded.Remove(enemy); return; }
- crowdedTime += checkInterval;
- if (crowdedTime < maxAttackDelay) crowded.Add(enemy); else crowded.Remove(enemy);
- }
Advertisement
Add Comment
Please, Sign In to add comment