Make a Multiplayer Shooter in Unity
- 5.5 hours on-demand video
- 3 articles
- 38 downloadable resources
- Full lifetime access
- Access on mobile and TV
- Certificate of Completion
Get your team access to 4,000+ top Udemy courses anytime, anywhere.Try Udemy for Business
- Create a multiplayer, networked game using Unity's Multiplayer Networking
- Build a tank arena game with top-down shooter mechanics
We learn to simulate a simple "lobby" to make the game wait for our players to connect.
Note: make sure that your m_playerColors array in the GameManager shows up correctly with the four different colors or else the GameManager will not properly increment the playerCount. Any colors will do but you cannot have less colors than the number of players connected.
In the beginning of this multi-part lesson, we import the Network Lobby asset from the Asset Store's Unity Essentials. We'll split our Project into two different scenes, the Lobby Scene (Lobby) and the Game Play Scene (Main).
We complete some basic setup to allow the new LobbyManager to replace our original NetworkManager from the previous tutorials.
In this continued lesson, we begin repairing our game now that our Network Lobby Manager has replaced the original NetworkManager. In this lesson, we should learn about:
- Lobby Player - this is a helper object to transfer data (playerName, playerColor) to our Game Player object
- Lobby Hook - this is a script that invokes OnLobbyServerSceneLoadedForPlayer as we transition to the gameplay scene
We make adjustments to the PlayerSetup component so we can store our Lobby Player's color and name string when we launch the game.
In the next installment of adding our Network Lobby, we:
- Refactor a lot of our existing code and delete logic made redundant by adding the Network Lobby (counting and tracking players, counting down at the start of the level). We also remove a few features that we'll add back later (scoreboard, enabling/disabling players).
- Change the GameManager's m_allPlayers List access modifier to static. This allows the Server to add players to the game freely from the Lobby without needing an instance of GameManager.
- Modify PlayerManager and PlayerSetup to Add or Remove from the static m_allPlayers.
By the end of Part 4, we should have most of our game back into working order.
- Here we do some major re-structuring of the game's MainLoopRoutine, where we allow the main game loop to run only on the server.
- Each subroutine (StartGame, PlayGame, EndGame) in turn triggers a ClientRPC to notify the clients when each phase of the game begins.
- After fixing the GetWinner method, we have a workable game that starts and ends with the Network Lobby.
Here we restore the scoreboard which consists of three parts:
- A clientRPC, RpcUpdateScoreboard on the GameManager, sends a list of player names and scores to the Clients
- The GameManager's UpdateScoreboard method pre-processes the data from the Server to pass to RpcUpdateScoreboard
- Then we invoke GameManager.Instance.UpdateScoreboard when we begin the game and whenever a player scores a point.
In this final update, we configure Unity Services for Multiplayer and get our game working across the Internet. Using the Network Lobby, you can create a game session online and then players anywhere in the world can join your session and you can duke it out in the arena!
Note: there is no SavePoint for this lesson. Just configure the Multiplayer Services on your dashboard to enable the service.
- A Mac or PC running Unity Personal Edition 5.3 or above
- A second networked Mac or PC for LAN Play (optional)
Important Note: Unity has announced future de-support for Unity Networking (formerly known as UNET). However, these tutorials should continue to work using Unity 2017.4 LTS and still provide a solid background in networking concepts.
If you want to enroll in this course we recommend using 2017.4 LTS in order for the lectures to work properly.
In 2019, we expect to discontinue this course in preparations for alternate networking solution. A completely new course is currently in development. Please see the GameAcademy[dot]school blog for updates.
This is a short course designed to introduce you to Unity's Networked Multiplayer system.
In it, we'll create a small tank arena shooter where we introduce:
Unity's Multiplayer Networking High Level API (HLAPI)
NetworkIdentity and NetworkTransform, to
Remote Actions, such as Commands and ClientRPCs
SyncVars and SyncVar hooks
NetworkManager, and NetworkManagerHUD
We will learn how to make our simple player drive around an arena level and connect with more than one player over a network.
This is an introduction to networking concepts as well as several components specifically made for Unity Multiplayer Networking.
Note: this course is designed for Mac and PC standalone (Multiplayer over LAN Network) and does not cover mobile devices.
- Developers with working knowledge of Unity 3D and C#
- This is NOT a beginning course. Do not enroll in this course without some experience in Unity 3D and C#