In this tutorial we are going to add a Potentiometer Based Steering wheel to control a Vehicle in Unity3D.
This was prepared for a workshop tutorial for a Maker Camp at Independent University, Bangladesh. For details check out Center For Cognitive Skill Enhancement (CCSE) at IUB.
Remember you can download the entire Unity3D project : https://drive.google.com/file/d/0B5e8rF1kJz8eY2FlQ1RabFo0LVE/view?usp=sharing
Now a friend of mine had setup the Arduino and Potentiometer for me , but it can be done by anyone following this tutorial : https://www.instructables.com/id/Arduino-Unity-Ra... . What was missing in that tutorial was the Unity3D code, which this instructable is all about.
Now the idea is your Arduino sends out a string through the USB. Unity3D is going to capture it and show it on the UI Text Mesh as seen on the image. This is what arduino.cs file does. Car Controller reads that string from the UI Text Mesh and converts it in to an integer. Then we use some simple if/else to set the angle of steering based on the potentiometer value.