Unity Multiplayer Games
eBook - ePub

Unity Multiplayer Games

  1. 242 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Unity Multiplayer Games

Book details
Book preview
Table of contents
Citations

About This Book

In Detail

Unity is a game development engine that is fully integrated with a complete set of intuitive tools and rapid workflows used to create interactive 3D content. Multiplayer games have long been a staple of video games, and online multiplayer games have seen an explosion in popularity in recent years. Unity provides a unique platform for independent developers to create the most in-demand multiplayer experiences, from relaxing social MMOs to adrenaline-pumping competitive shooters.

A practical guide to writing a variety of online multiplayer games with the Unity game engine, using a multitude of networking middleware from player-hosted games to standalone dedicated servers to cloud multiplayer technology. You can create a wide variety of online games with the Unity 4 as well as Unity 3 Engine.

You will learn all the skills needed to make any multiplayer game you can think of using this practical guide. We break down complex multiplayer games into basic components, for different kinds of games, whether they be large multi-user environments or small 8-player action games. You will get started by learning networking technologies for a variety of situations with a Pong game, and also host a game server and learn to connect to it.Then, we will show you how to structure your game logic to work in a multiplayer environment. We will cover how to implement client-side game logic for player-hosted games and server-side game logic for MMO-style games, as well as how to deal with network latency, unreliability, and security.

You will then gain an understanding of the Photon Server while creating a star collector game; and later, the Player.IO by creating a multiplayer RTS prototype game. You will also learn using PubNub with Unity by creating a chatbox application. Unity Multiplayer Games will help you learn how to use the most popular networking middleware available for Unity, from peer-oriented setups to dedicated server technology.

Approach

An easy-to-follow, tutorial manner that uses the learning-by-example approach.

Who this book is for

If you are a developer who wants to start making multiplayer games with the Unity game engine, this book is for you. This book assumes you have some basic experience with programming. No prior knowledge of the Unity IDE is required.

Frequently asked questions

Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes, you can access Unity Multiplayer Games by Alan R. Stagner in PDF and/or ePUB format, as well as other popular books in Informatique & Programmation de jeux. We have over one million books available in our catalogue for you to explore.

Information

Year
2013
ISBN
9781849692328

Unity Multiplayer Games


Table of Contents

Unity Multiplayer Games
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
Unity IDE crash course
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Unity Networking – The Pong Game
Introducing multiplayer games
Introducing UDP communication
Setting up the Master Server
NetworkViews and state serialization
Writing a custom state serializer
Using RPCs
Initializing a server
Connecting to a server
Connecting to the Master Server
Registering a server with the Master Server
Browsing available servers
Setting up a dedicated server model
Servers in Unity
Compiler directives
Setting up a server console without Pro
Loading networked levels
Creating a multiplayer Pong game
Preparing the Field
The Ball script
The Paddle script
Keeping score
Displaying the score to the player
Networking the game
Spawning paddles
The networked ball
Networked scorekeeping
The Connect screen
Summary
2. Photon Unity Networking – The Chat Client
Differences between PUN and Unity Networking
Setting up PUN with Photon Cloud
Using PhotonViews
Connecting to Photon and getting a list of rooms
Creating and joining rooms
Creating rooms
Joining rooms
Filtering results by user preference
Filtering arrays
Filtering and caching a room list
Automatic matchmaking
Finding friends
Syncing a level between players
Creating a chat client
The Connect screen
The Lobby screen
The chat room
Adding friends lists
Summary
3. Photon Server – Star Collector
Dedicated servers
Getting the Photon Server
Creating a server application
Creating a class library
Responding to operation requests
Deploying the server code
Connecting from Unity and passing messages
Creating a game logic class
Assigning player IDs
Building a star collector game
Preparing the class library
The Actor class
Sending an ID to a player
Keeping track of the game state
Spawning and picking up stars
Broadcasting events
Connecting from Unity
Creating/destroying actors
Controlling the player
Summary
4. Player.IO – Bot Wars
Player.IO versus the Photon Server
Getting and setting up a development server
Setting up the Unity client SDK
Connecting to Player.IO
Getting a list of rooms
Connecting to rooms
Creating rooms
Random matchmaking
Sending/receiving messages
Server-side code
Working with BigDB
Creating a simple RTS prototype
The server-side code
The client-side code
Summary
5. PubNub – The Global Chatbox
Overview of PubNub
Getting started
How PubNub works
Parsing JSON from PubNub
Building a PubNub interface
Creating a global chatbox application
Publishing chat messages
Displaying chat logs
Summary
6. Entity Interpolation and Prediction
Entity interpolation
The client-side prediction
Rigidbody simulation
Creating a networked object
Adding naive interpolation
Improving interpolation
Preparing for server authoritative movement
Implementing server authoritative movement
Notes on hacking
Summary
7. Server-side Hit Detection
Client-side versus server-side hit detection
Creating a testbed
Moving hit detection to the server
Entity rewinding
Summary
Index

Unity Multiplayer Games

Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2013
Production Reference: 1201113
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-232-8
www.packtpub.com
Cover Image by Prashant Timappa Shetty ()

Credits

Author
Alan R. Stagner
Reviewers
Clifford Champion
Fabio Ferrara
Sriram. A. S.
Acquisition Editor
Rubal Kaur
Lead Technical Editor
Madhuja Chaudhari
Technical Editors
Dipika Gaonkar
Mrunmayee Patil
Project Coordinator
Apeksha Chitnis
Proofreader
Linda Morris
Indexer
Hemangini Bari
Graphics
Abhinash Sahu
Production Coordinator
Alwin Roy
Cover Work
Alwin Roy

About the Author

Alan R. Stagner is an independent developer with a passion for Unity3D game development. He was introduced to programming by his father, he sought out different ways to create games in a variety of languages. Most recently, he found the Unity game engine and was instantly hooked, and discovered his love of multiplayer game development. He has also dabbled in database and server programming from time to time, mostly involving PHP and MySQL with recent forays into ASP.NET.

About the Reviewers

Clifford Champion has a broad background in software engineering, with years of experience spanning 3D games and Internet applications, and more recently in machine learning. He holds a degree in Mathematics from UCLA. In the past, he has worked as an integration and support engineer at Havok, and also as a lead interactive media and Internet apps programmer at PlainJoe Studios.
Now, he works for zSpace (zspace.com), a hardware/software company creating highly immersive, interactive 3D displays for classrooms, industry, and entertainment. At zSpace, he is a member of the software platform team, helping to enable the holographic-like experience on a variety of game engines and platforms, including Unity. Clifford can be found on Twitter at @duckmaestro and welcomes any discussions.
Fabio Ferrara is a game developer. He is working for Chubby Pixel, an independent game studio based in Milan, which he founded in 2012. They work thoroughly to bring to the users the best possible gaming experience. He has also collaborated for the publication of other books such as Unity iOS Essentials, Packt Publishing.
Sriram. A. S. is a software developer who is currently living in Pune, India. He works primarily in C/C++ and Java. He has been working with Unity 3D from its very early versions; and has developed codes related to its integration with features such as augmented reality, and shared them on his tech blog (http://mypersonalsoft.blogspot.com).
In his spare time, he works on a few open source software. And he also likes to experiment with various other technologies and ideas, along with his team of code passionate friends—the "Hobby Coders" (http://hobbycoders.com).

www.PacktPub.com

Support files, eBooks, discount offers, and more

You might want to visit www.packtpub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade t...

Table of contents

  1. Unity Multiplayer Games