Make a Multiplayer Shooter in Unity
4.7 (470 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
6,976 students enrolled

Make a Multiplayer Shooter in Unity

Build an online multiplayer top-down shooter (Unity 2017.4 LTS)
4.7 (470 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
6,976 students enrolled
Created by Wilmer Lin
Last updated 2/2019
English
English [Auto]
Current price: $15.99 Original price: $24.99 Discount: 36% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 5.5 hours on-demand video
  • 3 articles
  • 38 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Create a multiplayer, networked game using Unity's Multiplayer Networking
  • Build a tank arena game with top-down shooter mechanics
Course content
Expand all 39 lectures 05:40:18
+ Introduction
4 lectures 05:47
Unity 2017.4LTS: PLEASE READ BEFORE ENROLLING IN THIS COURSE
00:20

The journey of a thousand miles starts with the first step.

Preview 01:47

Before you take this course, here is what you ought to know...

Preview 02:07

Here we setup our blank project.

Preview 01:33
+ Gameplay Basics
6 lectures 41:24

Let's introduce our player tank!

Preview 07:02

In this lesson, we learn how to make our player move!

The PlayerMotor
10:05

Here we setup the basic components of our player and the master script, the PlayerController class, that connects them with our player input.

The PlayerController
06:45

A tank turret isn't a turret if it can't rotate!

Turret Rotation
11:21

Build our maze, one block at a time!

Maze Layout
04:17
+ Networking
18 lectures 03:01:21

Let's discuss the basics of multiplayer networking...

Preview 05:35

We add the Network Manager, a handy component that lets us manage our networked game.

The Network Manager
09:49

Let's see how we can make our tank movement synchronized over the network.

Multiplayer Movement
11:02

We label and color the tank so we can tell one player from the other.

PlayerSetup
09:25

Here we work on the Bullet and PlayerShoot scripts.  Our tank isn't a tank if it can't fire giant projectiles!

Shooting Mechanics (Part 1)
11:19

We complete the Bullet and PlayerShoot scripts except for a few nagging details...

Shooting Mechanics (Part 2)
12:54
Correction: NetworkTransform and Network Send Rate
00:18

... like shooting projectiles over Networked Multiplayer!  Here we also learn about spawning objects over the network and make our first networked Command remote action.

Multiplayer Shooting
09:53

We learn that bullets can hurt us!

PlayerHealth
15:51

We add a networked synchronized variable so that our health values can be synchronized over the network using Server Authority.

SyncVars
05:38

Here we learn how to use a new Remote Action, the ClientRPC, which will be instrumental in making our tank die over the network.

ClientRPCs and Death
08:05

We learn how to use the NetworkStartPosition component to spawn our player when it connects to the NetworkManager.  Then we learn how to repurpose them, so we can implement re-spawing in our gameplay scripts.

Respawning
11:40

We create the GameManager and make it a Singleton.

The GameManager (Part 1): The Singleton pattern
07:26

We use some coroutines to define our main game loop.

The GameManager (Part 2): The Main Game Loop
09:08

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.

The GameManager (Part 3): Connecting Players
15:55

Let's add a simple scoring mechanism.  This one involves quite a few small changes to existing components: the Bullet, PlayerShoot, PlayerHealth and PlayerController scripts!

Scoring
06:45

We have our scores stored with the PlayerControllers, now let's show them on the user interface.  

ScoreBoard UI
15:19

Let's add the Game Over message with a ClientRpc.

Game Over
15:19
+ Networking Review
1 lecture 02:28

A quick recap of what we learned today!

Review
02:28
+ Updates
10 lectures 01:49:16

We create a SpawnPoint script that allows us to respawn only at unoccupied NetworkSpawnPoints.

SpawnPoint Update
11:36

We repair some longstanding issues with the single-player shooter mechanics, including the occasional shooting through walls or bullets that strike your own player before they leave the barrel of the gun.

Addendum: Shooting Mechanics
13:05

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.  

Network Lobby Part 1
12:52

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.

Network Lobby Part 2
13:12

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.
Network Lobby Part 3
12:44

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.   
Network Lobby Part 4
18:31

In this session, we:

  • restore the EnablePlayers and DisablePlayers methods on the GameManager.
  • create an EnableControls and DisableControls on the PlayerManager
  • create a flag on the PlayerMotor and PlayerShoot to toggle the controls on and off
Player Controls Toggle
08:36

Here we restore the scoreboard which consists of three parts:

  • A clientRPCRpcUpdateScoreboard on the GameManagersends 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.

UpdateScoreboard
07:07

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.

Multiplayer Services
10:21

This is an experiment to add multiple maps to our game.

MultipleMaps
01:12
Requirements
  • A Mac or PC running Unity Personal Edition 5.3 or above
  • A second networked Mac or PC for LAN Play (optional)
Description


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

  • NetworkStartPosition


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.


Who this course is for:
  • 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#