Posted on 03 Aug 2020, in Programming.

Unity Has Some Great Tutorials

As a person who knows how to code in C#, I feel like Unity is an ideal game engine for me to learn game development. I did plenty of research on what I need to know about Unity. This involved going through tutorials with Brackeys and Zenva Academy but I think the most helpful was with Learn Unity. This is where I found the tanks tutorial which taught:

  1. Scene Setup for Tanks
  2. Tank Creation and Control
  3. Camera Control
  4. Tank Health
  5. Creating and Firing Shells
  6. Game Managers
  7. Audio Mixing for Tanks

unity-editor What made me excited the most about this project was that it had local multiplayer which means it could be played on one computer using one keyboard. They mentioned in the first tutorial that they had a version of the game with online multiplayer, this was later taken down due to their UNET legacy multiplayer solution being deprecated.

Adding Online To A Local Multiplayer Game

To prove my understanding of the tank tutorials and also learn something interesting, I made it a goal to add online multiplayer to the tank tutorial game. This involved me learning heavily from Alex Hicks in his Unity Multiplayer Tutorial series using NodeJS and Socket.IO. Since Unity currently only allows one project to be opened by one editor at a time, he also made a tutorial on how to work around it here. This is important because it allows the developer to test out the game with multiple players connected.

client-server

Heroku Deployment

Since the NodeJS tutorial runs locally through the command “nodemon [index.js]”, I needed to research on how to deploy a NodeJS app and found this tutorial on how to do it through Heroku. This is a great platform to host NodeJS projects as they have a free plan. The only issue I found was that it has a couple of minutes startup time to load since the server is not being run constantly.





Issues

I came across some issues during my time working on this tank project.

  1. The movement/rotation of the tanks is sent and synced on the nodeJS server, however, the bullets are not. The clients tell the server that a bullet has been fired but by that time the other tanks have probably moved, causing the game to be desynced. This can be resolved by adding the bullet fired and the bullet movement onto the server.
  2. Health needs to also be saved on the server otherwise the tank health will desync.
  3. There is no indicator of controls so the player will not know how to play the game.
  4. No lobby system.
  5. Not supported by WebGL. Possible solution with SocketIO for Native and WebGL builds.

Final Thoughts

Overall I learned a lot about Unity and NodeJS in this project. I will definitely be doing more Learn Unity tutorials and I hope that their new DOTS netcode gets released soon.

If you want to play, feel free to download the latest version here: TANKS Unity Multiplayer exe - Download. Just download, extract and run the file “TANKS test.exe”. Controls are WASD to move and space to shoot (holding it down will cause the bullet to fly farther).

Additional Resources