- Start by giving the number of boids to spawn (higher numbers can get laggy; between 20-60 yields the best results, in my opinion, but this depends on parameters and your computer) - Move your mouse to the left side of the screen to adjust the parameters List of parameters and their functions: + Alignment: How strongly the boids align (face the same direction). + Cohesion: The attraction force between boids. + Range: "How far the boids can see." The radius that the boid can detect/react to other boids (does not apply to mouse attraction). + Mouse attraction: Makes the boids attracted (or repelled when the value is negative) to the mouse pointer. + Resolve: how quickly the boids "adjust" their speed and direction. + Separation: the repelling force between boids. + Target speed: the "ideal" speed of the boids that they try to reach.
Made with the YouTube tutorial by @griffpatch (with some adjustments) I made this hoping to create swarming enemies for a game, but I decided it would also be a fun stand-alone project, so I shared it. Feel free to use the code for your own games or projects. Small tweaks from the original tutorial: - Added "Mouse Attraction" variable - Adjusted the way the colour of the boids changes based on direction (200 colour = 360 degrees rotation) so it looks smoother - Changed background fade effect to make trails less visible (I found them kinda annoying)