Building Multiplayer Games (w/ Unity)
-
Upload
noam-gat -
Category
Engineering
-
view
117 -
download
1
Transcript of Building Multiplayer Games (w/ Unity)
MULTIPLAYER MOBILE
GAMES (UNITY)
Hello!MY NAME IS NOAM GAT
CTO @ Tacticsoft
We make strategy MMOs
And you are?
1MULTIPLAYER GAMES
Definition and scope
“A multiplayer game is a game
played by multiple people”
- Captain Obvious
HOWEVERThere are several criteria to
distinguish between them, with
technical consequences.
Local (Single Device)
Badlands
King of the Opera
HOW DO THE PEOPLE PLAY THE SAME GAME?
Network
World of Warcraft
Clash of Clans
Hearthstone
Fifa ?
THIS (TECHNICAL) LECTURE IS ALL ABOUT NETWORKED
▪ Local Multiplayer is awesome
▪ IMO very unexplored territory
▪ But it is technically equivalent
to a single player game
Turn Based
Chess
Hearthstone
HOW OFTEN ARE PEOPLE UPDATED?
Real Time
World of Warcraft
Quake
Fifa
Clash of Clans?
Clients (P2P)
Old games
WHO RUNS THE WORLD?
Servers
New games
WHY DID P2P ARCHITECTURES FALL OUT OF FASHION?
▪ Servers are cheaper
▪ Less connectivity issues (port
forwarding etc)
▪ Easier to prevent cheating
▪ If one of the players has the
authority, it is called a server.
2MULTIPLAYER CHECKLIST
Building blocks for most
multiplayer games
MULTIPLAYER FLOW
Match
Conclusion
Lobby
LOBBY
▪ Devices don’t know about each
other yet
▪ They come to a central place and
get grouped to each other
▪ Not the most interesting of tasks
▪ Don’t reinvent.
MULTIPLAYER FLOW
Match
Conclusion
Lobby
MATCH
▪ One central entity (Server) is in
charge of the PERSISTENT GAME
STATE
▪ The clients send actions to it,
it notifies everyone of changes
to the world
▪ The server can be one of the
clients.
PERSISTENT GAME STATE?
The compact representation of the
game’s state. (The Model of MVC)
▪ Chess ? Game board
▪ FPS ? Player positions, stats
The clients have to be able to
build their perspective of the game
from it.
SINGLE AUTHORITY FOR EACH OBJECT
Make sure not to have two entities
in charge of the same object
▪ Character owned by client
▪ Projectiled owned by server
▪ Environment simulated separately
Multiple management causes desyncs,
flickers and unnecessary overhead
ACTIONS AND CHANGES
The client has to notify the server
of its actions. It can do so in
several ways:
▪ State updates (I am in X=1,Y=4)
▪ State deltas (I moved up)
▪ Actions (Jump)
The client has to update from the
server. Not always symmetric.
State Based
Robust
Simple
TRADEOFFS
Delta / Action Based
Secure
Compact
Cheap
Game
Conclusion
Lobby
Conclusion
In case of a metagame, server
updates “the bookkeeper” of the
match results.
▪ High scores
▪ Rankings
▪ XP
The bookkeeper is often the lobby.
3UNITY MULTIPLAYER
Let's build stuff.
Many different possibilities
▪ WWW Class (HTTP requests)
▪ Legacy Unity Networking
▪ UNet (New in Unity 5.1)
▪ Asset Store (Photon, Parse etc)
Many different possibilities
▪ WWW Class (HTTP requests)
▪ Legacy Unity Networking
▪ UNet (New in Unity 5.1)
▪ Asset Store (Photon, Parse etc)
UNet
UNet
Latest in-house evolution of Unity’
s networking efforts.
Lets you select which GameObjects
to synchronize, and how.
UNet (1 of 4)
Create a
NetworkManager.
Select Offline
(Lobby), online
(Match) scenes and
per-client Prefab.
Debugging Lobby
GUI
UNet (2 of 4)
Create a
NetworkIdentity.
Decide who takes
care of this
network-synced
object, and how
data is
transferred.
UNet (3 of 4)
Manage objects.
Enable / disable
components based
on whether the
client controls
this instance of a
player.
UNet (4 of 4, optional)
Manage sync.
Smoothly
transition between
state snapshots
rather than pop
between them.
UNet Video Tutorials
gamertogamedeveloper.com
21 episode long video tutorial of
creating a project with UNet.
Includes source code of final
project!
Legacy Warning
Legacy Unity Networking and UNet
don’t mix! Check documentation to
make sure you are using consistent
components.
Parse
Parse
A “Backend as a Service” owned by
facebook.
Not created just for game
development, but is useful in this
domain.
Parse (1 of 3)
Create objects.
Parse (2 of 3)
Retrieve objects (from the same
client or others).
Parse (3 of 3)
Query objects (from the same
client or others).
Parse
A simpler and slightly less “Unity-
ish” solution.
If you can define your multiplayer
layer as database interactions,
this is be a very simple way to
approach it.
Parse
Very well documented SDK.
Costs money to scale up, but has a
generous free offer that you won’t
pass until you have MANY users.
4HACKATHON TIPS
Let's build stuff.
AIM FOR THE SUNNY SCENARIO
Robust multiplayer
handling is hard.
Assume everything
with the connection
is fine.
FORGET ABOUT SECURITY / CHEATING
Its OK to give
clients more than
they need to know if
it makes things
easier for you.
For now.
GET THE NETWORKING POC DONE QUICK
Think of the
solution that suits
your game.
Get to a point where
two clients share
data ASAP.
LOVE THY NEIGHBOUR
You will share
similar difficulties
with the other
groups.
Use the power of the
group to solve
things faster.