Proof of concept to excercise building a basic multiplayer game in Unity and to explore having a non-Unity server built in Node.js (naive implementation).
The client game uses Extenject as DI framework; Socket.IO for Unity for connection with the server; and Moq for mocking in unit tests.
The server uses Socket.IO and is written in TypeScript and then transpiled via Webpack. It uses ESLint and Prettier for linting and formatting, and uses Jest for unit testing.
The socket sends the initial "connection" event to the server. The server calculates the initial position where to render the player and replies with a welcome message that has the position as payload. The client (game) then renders the local player.
Once rendered locally the game lets the server know this. The server registers the player and then proceeds to send existing players back and to broadcast the player to those other players.
The player moves locally, then this information is sent to the server for validation. The server validates the position, sends it back and also sends the confirmed position to other players.
The initiating game corrects position if it needs to and the other games render the position change for the player.
TBD
TBD
When a player closes the game the server updates the players list and informs other games about this.
- Movement: Rigidbody vs Translate
- Troubleshooting: character falling over problem
- Rotation with Rigidbody
- https://www.raywenderlich.com/9454-introduction-to-unity-unit-testing
- https://blogs.unity3d.com/2014/05/21/unit-testing-part-1-unit-tests-by-the-book/
- https://blogs.unity3d.com/2014/06/03/unit-testing-part-2-unit-testing-monobehaviours/
- http://adamsingle.com/unit-testing-in-unity-with-zenject-unirx-and-moq/
- https://www.youtube.com/watch?v=9AMPDjaSmjQ