要求Unity 2017.1.0 或更高版本。
Basic Fish Flocking behaviour with some game enhancing functionality. The fish will flock as expected within an invisible cube, the size of which can be of your choosing.
The Demo scene gives you a good idea of what is possible with this fish flocking script. If the Player moves too far from the shoal, the fish are disabled for performance and will remain like this until the player comes back in range and the fish "wake" up again.
We have set up two start markers and a finish marker, currently setup as huge poles in the water so you can see where the fish start and hang around, and where the shoal is slowly moving towards.
This allows you to not only have a realistic effect of fish flocking behaviour and movement, but also a moving shoal that will hang around the bounds of a defined hidden cube area.
This way, the shoal can wander along an invisible path, while flocking as they go. Unlike many games where the fish flock is just static, this flock could travel around your scene.