In the fall of 2017, I took a class that focused entirely on creative coding with the Unity engine. We focused exclusively on programing with C# (Sharp), an object oriented coding language. Given that my background is in sculpture, It is exciting to me that I can experiment with physics and 3 dimensional form in ways I simply not possible in the real world. I wont go into the semantics of the meticulous nature of programming to much, but here you will see a fun collection of fun video examples I have put together for your enjoyment!
The Exploding Box
For first project you will see below, I wanted to see what I could take advantage of the physics engine offered by Unity. By using the build in gravity, I was able to simulate a large falling objects from the sky. To make an interesting use of this, I placed a trigger on the ground that would cause the large cube to disappear and then spawn several smaller cubes at the same location; because the cubes have a ridged bodies component, physics applies and they cannot overlap one another, causing them to 'explode' and push away from each other. After which, I wanted to bring the cubes back to the starting location, so I used code to find the original spawning position and added force to make them return. You can see the result below!
Euler and Quaternions
This experiment is to look at the differences of effects caused by using either the Euler (pronounced oiler... bizarre, I know.) or Quaternion functions. Euler's use the rotation as Euler angles in degrees, and tend to have problems when rotating an object beyond 360 degrees due to gimbal lock. Quaternions however, are compact, don't suffer from gimbal lock and can easily be interpolated. Unity internally uses Quaternions to represent all rotations.
The video below demonstrated a few example of what I found to be achievable with these rotations. I added a Lerp function to make the cube a little more dynamic by giving them a start and end position in the space.
Raycast targeting and light manipulation
Using a place of origin, the direction it's facing and the maximum distance, Raycast can be used to determine when a collider is targeted. For this project, I simulated a search light that would fallow the position of the 'character' or target as it moves around the space. If the Raycast reaches the target the search light would change color indicating something is there.
The next experiment is using raycast with two kinds of trigger methods. One is connected to a player object that is moved around the screen by keyboard inputs, while the other is activated by drawing a line from the camera to where the mouse is clicked on the screen.
I randomly generated a 'city' of boxes that range from highest to lowest starting from the center by using curves that are offered by Unity. Then I used raycast to locate each of the cubes so that the 'player' can rotate and change the color of the individual object in front of it. I recycled the code for the exploding box, but instead of using gravity, I use a mouse click on a target object to trigger it.
This experiment uses gravity to create the effect of several bouncing balls, however when they hit the ground, force is applied upward making them shoot up like popcorn. I also added an 'onclick' function that changes the color of all the balls, just for kicks. This code was adapted from a 'flocking' project, which is what causes the balls to stay within proximity of one another.