I have question regarding flocking. Is it possible to develop a flocking algorithm where some objects can move independent some times and than flock at some other times. Basically what Im trying to do is make object A flock around object B for example and than at some point in time I want object A to move freely with no flocking for some specified amount of time, and than finally go back to flocking. If yes is their some demos or examples that anybody know about
Yea it's easy.
Your flocking algorithm would just have the agents wander until they come into a close proximity with other agents, at which point they will steer towards the group.
Sounds complex but the math is really easy. I was able to implement such an algorithm into Unity in a couple of hours, using these examples as my guide:
The code for the above examples is all provided, and only a few dozen lines long for each example. Also, the examples are interchangeable...so you could implement the "seek and arrive" functionality with the "wander" functionality with the "flocking" functionality, etc very easily.
Check out UnitySteer - that's a good flocking system. If isn't quite what you want, then surely it's easier to edit it than to make a whole new one?
I modified the seagull scripts on the original Island Demo to do pretty much that. They flock around a 'dummy' object I put in the scene. Easily can turn off their attraction to it, or have them flock toward different dummy objects.