Make a Multiplayer Shooter in Unity
4.8 (277 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
5,497 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Make a Multiplayer Shooter in Unity to your Wishlist.

Add to Wishlist

Make a Multiplayer Shooter in Unity

Build an online multiplayer top-down shooter
4.8 (277 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
5,497 students enrolled
Created by Wilmer Lin
Last updated 5/2017
English
English [Auto-generated]
Current price: $10 Original price: $95 Discount: 89% off
5 hours left at this price!
30-Day Money-Back Guarantee
Includes:
  • 5.5 hours on-demand video
  • 2 Articles
  • 38 Supplemental Resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Create a multiplayer, networked game using Unity's Multiplayer Networking
  • Build a tank arena game with top-down shooter mechanics
View Curriculum
Requirements
  • A Mac or PC running Unity Personal Edition 5.3 or above
  • A second networked Mac or PC for LAN Play (optional)
Description

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 is the target audience?
  • 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#
Compare to Other Unity Courses
Curriculum For This Course
38 Lectures
05:42:16
+
Introduction
3 Lectures 05:27

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
17 Lectures 03:01:03

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

... 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
+
Bonus Lecture
1 Lecture 01:46

More tutorials!

Bonus Lecture
01:46
About the Instructor
Wilmer Lin
4.8 Average rating
610 Reviews
6,591 Students
4 Courses
Game Developer / Visual Effects Artist

Wilmer Lin is a 3D and visual effects artist with over fifteen years of industry experience and has trained several hundred artists over the course of a decade. Now an independent game developer, Wilmer helps aspiring gamedevs learn the craft of programming and designing video games using Unity3D, Maya and Photoshop.