Let It Rain is a mini game where one player must try to get away from a rain shower while a second player tries to make it rain on the first using the left and right arrow keys to control the rain.
The Making Of - Tracking a Person through Kinect
In class we'd gone over several Kinect examples - one created a particle system when the Kinect could find a person standing in front of it, and another was a riff on Pong where mini cubes would drop from the top of the screen and the player could control a paddle to catch the cubes with their shoulders. The first version of Let It Rain (Assignment 3) was a combination of these two examples. I replaced the paddle with the particle system human body before copying over all the components that had been attached to the paddle to this new skeleton particle system. I hypothesized that this would give me a result where the cubes would now bounce off the particle system. Instead I found that the cubes were dropping straight through the system. With Stacey's help, I removed the particle system component and instead attached a new cube prefab to the joints.
<insert image here>
Once I had done that, I then attached a Box Collider component to the new prefab (SkeletonCube), which caused cubes to bounce off the joints. However, this lead to the skeleton rotating in a circle whenever a cube collided with it; the rotation would accelerate with each subsequent cube colliding with a joint. This was rectified by adding a RigidBody component to SkeletonCube; now that I could increase the angular drag to a value far higher than the rain cubes' effect on the joints and freeze the rotation on all axes the rotation problem was eliminated.
The Making Of - The Rain Shower
The rain shower is a particle system that's created at (0,0,20) above the player's skeleton, located at (0,-6,20). This was a modification made on the existing particle system from the paddle example. The shader was tweaked to be blue instead of white.
A new script was added called Move Rain, which allows the player to move the rain back and forth while also restricting the rain to the camera view.
The Making Of - Background
The background changes color using the script called RainSplatter, which builds off sample code from Unity's documentation on OnCollisionEnter. I wanted to have the background slowly alter to a darker color if the player was being rained on and back if they were not; I tried to alter the function from Mathf.pingpong to Mathf.Lerp to try this, but it ended up flashing on me in a nauseating way. With Mathf.pingpong, I get a similar effect, even if I want it stop when it reaches the second color I defined.
The Making Of - Audio
I got an audio clip of rain falling from the asset store and attached it to an empty object before setting it to loop.
I can't find a way to stop the background from changing colors once the rain starts to collide with the body - I wanted it to freeze on that color when the player is not being rained on. I built a script called StopRainSplatter and attached it to the BodyParticles but it doesn't work - the background instead constantly flashes back to the original color when I run the script, so I removed it.
Most code resources can be found within the scripts they applied to in the Scripts folder
Audio on Loop: http://answers.unity3d.com/questions/343057/how-do-i-make-unity-seamlessly-loop-my-background.html