Retro-style Car Game
In Unity, I created a retro-style car “game” (it’s not much of a game) with a cyberpunk, futuristic vibe. There are numerous physical interface controls that communicate with my Unity scene.
The Unity scene:
Importing assets from Sketchfab, I designed a Bladerunner-esque scene with car on a street at night. In the game, the car drives to the edge of the road. There seems to be no road ahead. Suddenly, the car hovers over to a structure radiating cosmic particles. This is my sound source. The sound is 3D spatial blended so when the car gets closer to the source, the music gets louder.
The Interface and Arduino Code:
I used three sensors: an LDR to control the headlights of the car, the potentiometer to control the volume of the music, and a button to control the blast-off particle system.
To get my sensors to respond in the Arduino IDE, I used this code:
The Unity Code:
I wanted my car to behave in a certain way. 1) move in direction with my arrow keys and 2) hover when you press the spacebar. Here is the Unity script:
I also wanted my sensors to control certain behaviors in the scene. To bridge the connection between the physical and the virtual, I downloaded Ardity for the Unity store and used this code:
Overall, I learned a lot through this project. There are, of course, behaviors I wish were more organic and better executed. I wish my car behaved more like a car (the car tires turn with the car, the car tilts when it flies, etc…). I was able to expand my knowledge of C# scripting, but there’s so much more to know. I feel like I am at a standstill with my physical interface scripting. I could get something turn off and on, but that’s about it. What if the car turned to my potentiometer? Or the potentiometer was the trigger that made the car hover. Moving forward, I will explore more creative ways to involve my physical components.
Here is a 360-degree video I made with the Unity Recorder. I will definitely be exploring the applications of this further as well.