The creature in the game is called the Darting Flock. In the prototype, the center (shown as a white rectangle) is the controlling element. The green fliers try to guard it. As the player shoots their way through the flock, the controller creates more fliers that encircle it. Some even dive-bomb you. The fun is trying to cut a hole through the flock and shoot the center while dodging incoming fliers.
As described by the "boids" system, flocking works by having many objects follow a small set of steering rules. I've simplified the system more but also added some changes to it to keep it interesting. The new actions are: 1. Find the closest neighbor. 2. Follow a target position offset behind the neighbor by a random angle. 3. Recheck for the closest neighbor every few seconds. The exceptions are a few 'leader fliers' which need to know where the flock is going. They are forced to follow the controller at a certain distance, while all other fliers connect from there. When the leaders follow the controller, they are actually following a position just outside the controller that orbits the controller itself. This indirection gives even more motion to the group.
The blue lines in the image are between the flier and their target. The white lines are from the flier that is getting followed by another flier. You can trace the chain of fliers as they follow each other to see the order.
Flocking can be more expensive than homing from a processing standpoint since every flier has to check the distance to every other flier. By staggering and delaying how often this happens we can ease the burden on the processor.
Several neat behaviors come from this. The fliers may fly outwards suddenly but will eventually come back around, usually in a wild spiral. When the player kills fliers, for a few seconds some of them will follow their dead friends down before reacquiring a new neighbor! This makes the fight a lot more exciting and can create some really intelligent looking emergent behavior from relatively simple programming.
Không có nhận xét nào:
Đăng nhận xét