"Into the Deep" (2023) is a Stand-alone Virtual Reality experience that lets the user swim around an (at-first) colorful and vibrant coral reef. The user watches as the color leeches from the coral, bleached, like many of our current reefs.
"Into the Deep" runs on the Oculus Quest 2, using Unity 2020.3.17f1.
The schools of fish were scripted in C#, following the rules of Boid/flocking movement. The AI uses separation, cohesion, and alignment to mimic the behaviors of schooling fish. These schools also have their own movement around the terrain, using Unity's NavMesh. I plan on adding obstacle avoidance and goal seeking in coming iterations, as well as customizing the AI to different types of fish. I also plan on adding predator avoidance and avoidance of the playable character.
To start out the Boid entities were given a random position within the bounds of the Boid origin point. These entities were first controlled by separation and alignment. A specific entity takes into account the closest entities (neighbors) to determine its direction of movement. The direction of the entity is controlled by the previous direction of the entity and the direction of the entity's neighbors. However, if the entity is too close to the neighbor it will avoid neighbor.
The entities were then made stay within the bounds of the Boid Origin. This was done by changing their direction to also account for the Boid Origin point and make them exclusively move back to the point once they left the bounds. Once the entities re-entered the bounds, the rules of separation, alignment, and cohesion take over. However, after running the Boid script over a period of time, the entities tended to swirl around the origin point and remain there. The cohesion was preventing more random movement from occurring. To remedy this, instead of the entities taking into account the Boid Origin, they take into account a random point within the origins bounds, that is changed at random intervals. This provided behavior that remained random even as time passes. The video below, "randomized cohesion" is how the Boid script performs after 10 minutes running.
One of the behaviors I wish the entities to perform is the avoidance of obstacles, predators and the player. Currently I am aiming for the entities to navigate around tall, thin objects while retaining their flocking behavior. To do this I used the same method used to avoid other entities. Instead of using the distance between the three-dimensional position of either object, I used the two-dimensional (X, Z) positions of either object. This insured at any y-position, the tall-thin object will be avoided. The next step will be adding in more obstacles, and possibly experimenting with different sizes. I am also interested in seeing how to use this method to also avoid the player and predators.
Instead of using the traditional joystick input most VR experiences use for navigation, I decided to create a movement-based input for this project. The User is able to move forward by pressing down both controller's grip buttons and moving their hands in a breaststroke-like motion. This movement pattern is meant to mimic a swimming motion and add to the immersion of the experience.
The Player Controller Script uses Unity's OpenXR package and Input Action Management to map the grip buttons, and Unity's OVRPLugin to capture the velocity of the controllers. When the grip buttons of the controllers are simultaneously pressed, the Controller script captures the velocity of each of the controller's motion. This Velocity is used to apply a force to the player, moving the player proportional and opposite to the controller's velocity. A drag force is also applied to the player, to slow them down in a realistic manner. This allows the player to move forwards, back, or up and down, making it feel as though the user is swimming through the experience.
All of the plants and corals were modeled by me in Maya 2023.1. The rocks were found on the unity asset store (credit below). Terrain was designed using Unity's terrain tools. In future iterations I plan to model my own rocks and create more types of coral. I also plan to make more complex textures for the corals, instead of using the currently flat looking colors. I want to add more realism to the corals and other plants going forward.