Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Unity Multiplayer Games

You're reading from   Unity Multiplayer Games Take your gaming development skills into the online multiplayer arena by harnessing the power of Unity 4 or 3. This is not a dry tutorial ‚Äì it uses exciting examples and an enthusiastic approach to bring it all to life.

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781849692328
Length 242 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Stagner Stagner
Author Profile Icon Stagner
Stagner
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Unity Multiplayer Games
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Unity Networking – The Pong Game FREE CHAPTER 2. Photon Unity Networking – The Chat Client 3. Photon Server – Star Collector 4. Player.IO – Bot Wars 5. PubNub – The Global Chatbox 6. Entity Interpolation and Prediction 7. Server-side Hit Detection Index

Automatic matchmaking


Many games do not use a lobby. For example, console games often opt to randomly match players together rather than allowing them to browse a list of games (which could be unwieldy with a controller), or some games also have a "Quick Play" button in the lobby which allows the user to jump right into the action without having to browse the server lists. Usually, players can specify a preference, such as which map to play on, or what game mode they want.

Luckily, random matchmaking in PUN is very easy.

In PUN, you can call the PhotonNetwork.JoinRandomRoom function. This function takes a Hashtable of expected properties, and the desired max player count. It will attempt to join a random room, which will either call OnJoinedRoom if a room was found and the client was able to connect, or OnPhotonRandomJoinFailed if no room could be found (usually, this means all rooms are full, or no rooms are available).

Our lobby example might have a "Quick Play" button to do this:

// if quick...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images