It was a long and winding odyssey, but I present to you the screencast of my final project (Note: Without the audio, this does not have nearly the full effect. If someone knows how to take a screencast w/audio, I would love to redo this):
If you have the chance, view the full file on Unity in the Innovation Lab, as audio plays a huge role in the story. *I do not own the rights to any of the music and as such this is for personal use only*
The reason I say this experience was an odyssey is because originally, I was going to do a 360 video on the IMAX dome at the Museum of Science and Technology in Syracuse. I showed up and got some really interesting shots, did an interview, set up the camera in a couple of intriguing locations. I wanted to start editing the footage, so I took the microSD card out of the Gear 360 I used and put it in one of the card readers Newhouse provides. Big mistake. I tried to adjust it, and the SD card got stuck in the card reader. As I tried to lodge it loose and pulled, the card snapped into pieces. I could not believe my eyes; I have never seen anything like this happening. I left the pieces of it in the top right glass shelf in the I-Lab because I know if I didn't see it, I would have trouble believing it. The experience was absolutely bonkers. Compounding my problem, I only had about a day left in Syracuse.
I ruled out reshooting the 360 video, and against some of my better judgement (and the advice of a couple of people), I decided to do a Unity scene. This let me do the project on my terms and without the need for external equipment prone to freak accidents. However, I am not exactly what you would call gifted with Unity, and I knew this going in. I am pleased with the final result though.
I spent about six hours trying to do a Unity scene in the I-Lab my last day in Syracuse, but I could not get Playmaker to work. Jackie Prager graciously spent some of her time studying for finals helping me with the scene, but we still were not able to make it work, even using the same logic as she did. We had a couple of problems, primarily moving objects that were not the FPS Controller. I tried to make a Minotaur guide you through a beachside barbecue (why not I guess). Essentially, I tried to trigger the Minotaur to teleport to where the FPS was, and then walk together to the beach. My logic for the first bit was sound, as it progressed through all of the FSM states as it should have, but when it got to the finished event, the system would exit the FPS view for some reason. If anyone has ever encountered this problem, I would love to hear your thoughts.
After that debacle, I decided to just download Unity on my Mac so I could just work on it when I went home. I started to scan my childhood for ideas. I always loved the Triwizard Tournament in The Goblet of Fire, so like the great J.K. Rowling herself, I lifted the idea of a maze from her, complete with a portkey at the end! This maze doesn't involve death but instead fun music selections from the 70s and 80s! The maze will also let you know sometimes if you've hit a dead end. In this process, I figured out how to do two things I hadn't been able to do before: get sound to play only when you want and in a certain area, and to teleport through the scene!
Here is a step by step explanation of how to play sounds when and where you want them:
- Create a cube, place it where you would like the sound to play, turn off the Mesh Renderer if you want the cube to be invisible, select box collider and make sure the "Is Trigger" box is checked. Adjust size of collider to your needs.
- Next, add a component by either going to the window Component at the top of the browser or scroll down on the Inspector to the right of your screen and click on add component. In both scenarios, add an Audio Source component. For the AudioClip, select the sound you want (either import a song or Youtube video or get one from the Assets Store). Make sure you deselect Play on Awake, otherwise it will just play throughout the whole scene. Set the Spatial Blend to 3D, and select a distance and manner in which you would like the sound to play. I preferred a linear rolloff to allow the sound to fade smoothly as you get further away from it, as opposed to the logistic rolloff which is more abrupt. Below is a picture of what my Inspector for my AudioSource looks like, featuring the Guns & Roses hit classic, Welcome to the Jungle:
4. Either drag the script on top of your cube in the Hierarchy tree to the left, or add another component, select script and select the corresponding one. A window in Inspector should pop up, with the name of your script at the top and below it, and the name of your variable at the bottom of the three. Across from your variable, once again select the sound you want as the AudioSource.
By changing your rolloff, the minimum and maximum distance and the size of the box collider, you can effect when the song is played (through triggering of the box collider), how long it plays and how far it can be heard (both through the distance and rolloff). For example, by setting the box collider size to just one, I could get the music to play as soon as you walked through an area.
Teleport: Jackie Prager has written on this subject before, but I have some things to add. Essentially, I was only able to transport the FPS throughout the scene with the Playmaker action Move Object, not I Tween. For whatever reason, I Tween did not work with the FPS. The version of Unity on the Mac in the Innovation Lab did not have Move Object; I am not sure why. The logic is pretty basic. It is just two events, with three total transitions. Create an FSM on a cube from where you want to transport from. Add your first state and name it Trigger Event, or something similar. Your other state should be named whatever is you want to happen (for example, teleport). In the first state, create a transition and select "TRIGGER ENTER". In the second, create both a "FINISHED" transition and a "TRIGGER EXIT" one. In the second state, select action browser and 'Move Object'. Specify the game object as the FPS and the destination as whatever cube you want to teleport to. Set the time and speed to zero (not none), and specify the finish event as "TRIGGER EXIT". This should allow you to move the FPS wherever you want within your scene. Here is a photo of my logic: