
EX 1 Creative Code - XR Dev
Description:
Explore generative art, self-replication and recursion. Using coroutines, instantiation, transform properties, shaders, conditionals, and randomness, create a system that generates a form of dynamic work. Experiment with code to generate something visually interesting and organic yet alien.'
In this project, I created an art and music piece. Every half a second, a new rock is generated at a random location. This rock has a random color and then falls onto an assortment of panels. When contact is made, there is a random chance that a corresponding piano sound effect will play. Each rock changes colors to be some shade of purple/pink. After ~30 seconds, the scene resets and the rocks begin falling again. This project contains sound.
Code Breakdown:
- Code
- Main: Starts 2 Coroutines (MakeRocks | ResetRocks)
- ChangeColor: Assigns color to rocks
- Clink: Detects collision and plays according sound effect
- CollisionMultiply: Detects collision and duplicates/removes rocks
- RemoveObjects: Destroys rock after randomized lifespan
- Main
- Make Rocks: Randomly chooses position and rotation of each rock and instantiates a new one every .5 seconds.
- ResetRocks: After 30 seconds, destroys all existing rocks (except for the original rock)
- ChangeColor
- Gets current color and starts color swap coroutine
- ColorSwap coroutine randomly chooses a new material color and replaces the rock color after .4 seconds
- Clink
- Detects when a collision occurs
- Based on a variable established in the inspector (values from 1 - 15), there is a chance that the audio plays each time a collision occurs.
- Different audio scripts are assigned to different panels.
- CollisionMultiply
- Detects when a collision occurs
- Starts two functions: DuplicateObjects and RemoveRocks
- DuplicateObjects: There is a 5% chance that a collision with another object will cause the rock to duplicate. If this 5% chance occurs, the script references the rock prefab and instantiates a new rock at the same position.
- RemoveRocks: All generated rocks have the tag rock. If the number of objects with the rock tag exceeds the maxRocks variable, all new rocks are deleted.
- RemoveObjects
- After a rock is generated, waits for a random time between 0 and 10 seconds and then destroys that game object.
Credits:
- Piano chords are recorded by myself
- Piano notes:
- Sound Effect by freesound_community from Pixaba
- Skybox:
| Status | Released |
| Category | Other |
| Platforms | HTML5 |
| Author | pteli_2003 |
| Made with | Unity |
| Tags | art, Music, No AI, random |
| Content | No generative AI was used |
Leave a comment
Log in with itch.io to leave a comment.