Custom Controller for Self Made Game
by Mordock1 in Circuits > Arduino
116 Views, 0 Favorites, 0 Comments
Custom Controller for Self Made Game
For this project, made during an assignment for University of the Arts in Utrecht(HKU), I made a controller for a simple endless running made in Unity. This controller has one button to control the game character and 3 lights which show the players health.
The actual game for this project can be found on Github: https://github.com/mordock/HKU_ITTT
During the initial stage of research I knew I wanted to do something related to my studies, Game Art. I came up with a few ideas such as reading a screen to play a game and connecting the Arduino directly to a game in some way. However I wanted to focus more on the game making together with the Arduino so I decided to make my own simple game.
Supplies
Components
- Arduino Uno
- 3 led lights(1 red, 1 green, 1 blue)
- 1 simple button, 2 pin
- 4 resistors(300-500)
- Copper cables
Controller
- 2 3D printed parts which fit together(see Github for used 3D models)
- A 3D solution to hold your arduino and plate with parts(I used Lego)
Tools
- Soldering Iron with solder
- Stripping pliers
- Cut pliers
- 3D printer
Unity
- Unity version 2021.3(or similair)
- Visual Studio
- Unity Hub
Build Unity Game
Here you can see the code used to connect to Arduino. At the start of the game I open a stream and I constantly wait for data from the Arduino. Based on this data I have to jump.
This also includes some methods used by other classed which can be used to send data to the Arduino, such as amount health.
The rest of the game is a simple endless runner which spawn obstacles which the player has to jump over.
Arduino
Here is the Arduino code used to connect to my Unity game. The only thing you might have to change is the connected port.
The first picture is to show how my lights and button are connected to the Arduino. In the second picture you can also see a first version which is not yet soldered.
Downloads
Housing
For the housing, or the actual controller I modelled 2 pieces which fit together. Here you can also see a failed first version. This was due to the walls not being thick enough and the speed being to high. Pay attention to this when printing yourself.
Inside Housing
The inside housing is made with a custom Lego build. It is a simple open cube with 2 platforms where the Arduino and connection plate can both be stored without touching each other.
Conclusion
During this project I gained a new appreciation for physical electronics and its uses. I had used Arduino before and I wasn't a fan. However this project helped me change my mind to see the use and fun in building your own electronics.
Also I improved my soldering skills, this is something I had done a long time ago but now I feel confident in my skills.
For this project I created my first 3D printed element. It took more than 1 try but in the end I got a print with which I was happy and fitted all components.
Lastly I also improved my Unity/C# skills, for this project I had to connect to an external physical device, receive data from it and send data to it. After some research and trail and error this worked perfectly.