A Simple Gift: A Humble Flocking Behavior

Hey everyone
recently, i came a across a really interesting algorathim

Boid Flocking.
i know most projects in here are 3D, but it is rather simple to switch it from 2D to 3D, and im pretty sure most people taking the course by now should be able to “fit it” into their projects. if they need to or want to, whether it is 2D or 3D.

and this is my implementation of it.

and i’d like to share with everyone here my code in which i made it.
it is really interesting, and i can see some very interesting uses of it. (for Ben’s Game, i can totally see a swarm of bees being one entity (enemy) using this behavior while chasing the character :smiley: )
and of course, there is a lot of room for optimization, but even without optimization, it kind of is cheap, way cheaper than physics. (image having rigid bodies and mesh colliders on say, a bunch of bees? pretty sure, this will cost way less :slight_smile: .

this is the link for the package.
enjoy, and i really hope it is useful.
if you wind up using it, feel free to share your work if you wind up using it.
there is also a simple test scene which you can find a working example of it.

(by default the boid targets will follow a specified target transform (set at the boids controller).

if the rotation is annoying, it can be turned off by a simple bool. of course, you can make the rotation you like most in accordance within your game :slight_smile:

http://www.filedropper.com/boidflockingbehaviorpackage_2

4 Likes

That is very interesting. This all seems to be coming from a Computer Science major or a master’s program :slight_smile:

Do you have any intention to apply this in your games?

1 Like

thanks, i actually study physics, and i already did apply it in one of games which was made in ludum dare

i plan to utilize it even more, once i start making an RTS in the future.

That is so cool. I did my BA in physics. I think it naturally helps with game design.

1 Like

Privacy & Terms