Last active
September 13, 2022 21:00
-
-
Save sponrad/91b1a4b05036808228a203066b94d817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Vector3 rule2(BirdControlScript ej) | |
{ | |
Vector2 center = Vector2.zero; | |
for(int j = Random.Range(0,1); j < BirdList.Count; j+=2) | |
{ | |
BirdControlScript e = BirdList[j]; | |
float enemyDistance = Vector2.Distance (ej.transform.position, e.transform.position); | |
if (e != ej && enemyDistance <= enemyDistanceRadius) { | |
center = center - (Vector2)(e.transform.position - ej.transform.position); | |
} | |
} | |
return center * 0.5f; | |
} | |
func boid_rule_2(): | |
# separation rule | |
var move_away = Vector2.ZERO | |
var birds = $BirdsNearbyArea2D.get_overlapping_areas() | |
for bird in birds: | |
move_away -= (bird.global_position - global_position) | |
return move_away.normalized() * 0.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment