Published 17 days ago
Wait what?!
This is Roll A Ball created with UNET (Unity Networking) system. This will allow other people in the room to join you to play competitively.
Background Story
The background behind this was that I struggled learning UNET when I was taking a Game Design class. I have seen a lot of networking tutorials and it didn't help me out a lot. A little past the midpoint of the semester, I started to understand better little by little. To fortify what I learn at the time, I would make small prototypes like just getting the ball to move around, transferring values from the offline/lobby to the online scene, keeping the later joined player up-to-date with the game with others and etc. This is my fifth or sixth iteration of UNET Roll A Ball. It may be excessive, but I learned something new in each versions.
I want to share what I know as of now with everybody who watches the tutorial on YouTube or downloads the completed project from I do hope that this will help the beginners learn UNET or show those who do know UNET a different perspective or approach to things.
Method(s) Used
In this project, I used or done something like:
  • Network Manager: This deals with connecting the player to the online scene and spawn a player prefab that will act as a connection object for the player. **Note: The player would not be controlling this particular prefab.
  • Network Identity: The Game Objects that have the Network Identity do NOT have either options 'Local Player Authority' or 'Server Authority' checked.
  • Ownership: The player prefab, the one that connects the player to the online scene, will OWN and UPDATE the ball that got spawned via code using NetworkServer.Spawn() function. This will enable the player to not be kicked out of the network if his/her player prefab gets destroyed.
Here is the "Ownership" code snippet that is attached to the Player Prefab:
On the actual Ball that the Player controls:
  • Moving the ball: The Ball Prefab already has a rigidbody and Network Transform to help sync across the network, so that everybody can see where everybody is. The movement code on the other hand is circular like Unity's Remote Action Chart. Here is the link:
  1. Getting the movement input from the local player. In the tutorial, I have the Command function to be called Cmd_IWantToMove().
2. On the Server Side in the Player Prefab object (same script as the one in the ownership snippet) We pass in the ball that calls the command to make sure that requested ball gets its response, MoveMe():
3. Lastly, we go back to the Ball script (MyGamePiece) and update its velocity there on the server side. This will make us actually see the ball move around for the clients/other players.
In the End:
Unfortunately, I'm not going to talk about everything about this project here. That would be a long, long, long article. I'll would like to keep it short, so I don't scare you and other readers, haha. I apologize if I make any mistakes. I'm not an expert at UNET, but I would like to get better at it.
Again, I do hope this will help others with UNET and be comfortable with it a least. My Game Development teacher showed me this method and it works for me, so I thank him for that. Also, thank you to the Roll A Ball tutor guy too. I still look back to Roll A Ball for help, haha.
I'll provide the link to the completed project. A little warning is that the names in the tutorial and in the completed project are different. I have included a ReadMe.cs in the project to help out with that. Thank you! :D
Here is the link to completed project:

Andre Mercier
Indie - Other