CNA Samples

Flocking

Ported from Microsoft's XNA 4.0 Flocking sample.

Source for this sample on GitHub ↗

A flock of small birds scatters around a cat on a blue field, with two distance sliders above. Play ▸

Opens in a new tab. Press Y to add the cat, then tune the flock with the arrow keys.

About this sample

Each bird aligns with nearby birds, moves toward the group, keeps its distance from close neighbours and flees the cat. Change the detection and separation distances to see how the flock responds.

Controls

ActionKeyboardGamepad
Select a distance sliderUp / DownD-pad Up / Down
Change the selected distanceLeft / RightD-pad Left / Right or triggers
Add or remove the catYY
Move the catW / A / S / DLeft thumbstick
Reset the distancesBB
Reset the flockXX
ExitEscapeBack