[005] Boids
[005] Boids
[20h] Boids using Area2D & PhysicsShapeQuery
[Aug 16, 2023] 4h
- window size - 512 x 384 (32 x 24) 16px
- Compute Shader study and review
[Aug 17, 2023] 6h
- Boids study and review
- UI controls
[Aug 18, 2023] 4h
- Boids Signal vs Query research
- UI controls
[Aug 19, 2023] 4h
- Boids + Compute Shader
[Aug 20, 2023] 2h
- Rendering Server Rotation
References
- smarter everyday [youtu.be/4LWmRuB-uNU]
- boids pseudo code [vergenet.net/~conrad/boids/pseudocode.html]
- boids more information [red3d.com/cwr/boids]
- compute shader in godot [youtu.be/5CKvGYqagyI]
- compute shader example [github.com/godotengine/godot-docs/issues/4834]
- birds in flight [youtu.be/V4f_1_r80RY]
ERROR: memory access out of bounds
- compute shader is not yet supported in browsers ?
Boids
[pseudocode]
generate boids
LOOP
vector_a = rule_coherence()
vector_b = rule_alignment()
vector_c = rule_seperation()
velocity += vector_a + vector_b + vector_c
position += velocity
rule_coherence() # coherence - average position
var range = 50 # how far boid can see
var factor = 0.005
var total_boids = 0
var total_position
var avg_position
get all boids in range
for each boid in range:
total_position += boid.position
total_boids += 1
avg_position = total_position / total_boids
return (avg_position - boid.position) * factor
rule_alignment() # alignment - average velocity
var range = 50 # how far boid can see
var factor = 0.05
var total_boids
var total_velocity
var avg_velocity
get all boids in range
for each boid in range:
total_velocity += boid.velocity
total_boids += 1
avg_velocity = total_velocity / total_boids
return (avg_velocity - boid.velocity) * factor
rule_seperation() # seperation - to avoid others
var min_dist = 20 # distance to stay away
var factor = 0.05
var move = 0
get all boids in range
for each boids in range:
move += boid.position - other_boid.position
return move * factor
| Status | Released |
| Platforms | HTML5 |
| Author | QuietGodot |
| Made with | Godot |
Download
Download NowName your own price
Click download now to get access to the following files:
boids.zip 7.3 MB

Comments
Log in with itch.io to leave a comment.
The boid counter can go below 0 and into the minuses
Thank you for pointing this out, have now added a limit to the count.