Predators and prey

 Adding predators involved several steps of modifications to the original simulation, primarily in the Unity settings. First we need a school of fishes using the new predator type which involves making a few prefabs, or prefabrications, of a predator fish that we can use as a template. Doing so was slightly tricky as importing third party models does not seem to be completely standardized and led to some issues in getting the shaders to work. Once this was resolved it was merely a question of adding the scripts to a basic gameobject which added required code for fishes to work, turning each separate fish into a boid. From this point a new school of fishes was required, using the predator prefab as a template to create more fishes. This was easily accomplished by copying the school of fishes and changing the variables to turn it into a school of predators. However, for this to do anything the behavior of fishes had to change based on their type. To do this the Boid class was changed to add a predatory force towards a fish classified as prey for this specific type of fish. To facilitate classifications a new class was added which can perform lookups to find which types prey on others, which also allows for a function to determine if one specific fish should prey on another specific fish based on which school they belong to. In the current implementation there is only predators and prey, although this could easily be extended by adding more entries to the lookup class and adding a corresponding school to the scene. At this point the fishes being consumed by predators needed to be removed from the simulation, although this required a lot of integration with the optimized solution for GetNeighbors to fully remove each object. In order to create more interactions between predators and prey another force was also implemented, causing prey to flee from predators near them. Without this force the simulation largely devolved into the predator speeding around and eating every fish without much to stop it. After some tweaks the system was fully complete, with fishes being hunted by a predator in the shape of a great white shark. 



Kommentarer