Unity Multiplayer Games

所需积分/C币:9 2015-02-13 19:47:36 1.76MB PDF
2
收藏 收藏
举报

Unity Multiplayer Games
Unity multiplayer games Copyright o 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 cither 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: December 2013 Production Reference: 2251113 Published by Packt Publishing Ltd Livery place 35 Livery street Birmingham b3 2PB, UK ISBN978-1-84969-232-8 www.packtpub.com CoverImagebyPrashantTimappaShetty(sparklingspectrum.123@gmail.com) Credits Author Project Coordinator Alan R. stagner Apeksha chitnis Reviewers Proofreader Clifford champion Linda morris Fabio ferrara Sriram.A S Indexer Hemangini bari Acquisition Editor Rubal Kaur Graphics Abhinash sahu Lead technical editor Madhuja chaudhari Production coordinator Alwin Roy Technical editors Dipika gaonkar Cover work Mrunmayee Patil Alwin Roy about the author Alan R. Stagner is an independent developer with a passion for Unity 3D 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. I'd like to thank my family and friends of course - my father is the entire reason Im a programmer and has helped me every step of the way. Everyone i know has been incredibly supportive. I'd like to thank the unity community-without themi don 't think i would know Unity like I do today. I'd also like to thank Unity for providing such an awesome platform and making it so easy for me to write my first multiplayer game about the reviewers Clifford Champion has a broad background in software engineering, with year of experience spanning 3D games and Internet applications, and more recently in g 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(space. com), a hardware/software company creating highly immersive, interactive 3D displays for classrooms, industry, and entertainment At sPace, 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 aduckmaestro 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 very early versions; and has developed codes related to its integration wilh om its works primarily in C/C++ and Java. He has been working with Unity 3D fr features such as augmented reality and shared them on his tech blo 8 (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 passionatefriends-thehobbyCoders(http://hobbycoders.com Www. Packtpub. com Support files, eBooks, discount offers, and more Youmightwanttovisitwww.packtpub.comforsupportfilesanddownloadsrelated toⅴ our book Did you know that Packt offers e Book versions of every book published, with PDF andepuBfilesavailable?Youcanupgradetotheebookversionatwww.packtpub com and as a print book customer, you are entitled to a discount on the e book copy Get in touch with us at service@packtpub com for more details Atwww.packtpub.com,youcanalsoreadacollectionoffreetechnicalarticles sign up for a range of free newsletters and receive exclusive discounts and offers on packt books and ebooks PACKTLIB http://packtlib.Packtpub.com Do you need instant solutions to your it questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire brary of books Why Subscribe? Fully searchable across every book published by Packt Copy and paste, print and bookmark content On demand and accessible via web browser Free Access for packt account holders IfyouhaveanaccountwithPacktatwww.packtpub.com,youcanusethistoaccess PacktLib today and view nine entirely free books Simply use your login credentials for immediate access Table of contents Preface Chapter 1: Unity Networking- The Pong Game 7 Introducing multiplayer games Introducing UDP communication 9 Setting up Master Server 10 Network views and state serialization Writing a custom state serializer Using RPcs 13 Initializing a server 15 Connecting to a server 16 Connecting to Master Server 18 Registering a server with Master Server 19 Browsing available servers 19 Setting up a dedicated server model Servers in Unity Compiler directives 22 Setting up a server console without pro Loading networked levels 26 Creating a multiplayer Pong game 28 Preparing the Field 29 The Ball script 31 The Paddle script 34 Keeping score 35 Displaying the score to the player Networking the game 39 Spawning paddles 41 The networked ball 44 Networked scorekeeping 47 Table of contents The connect screen 50 Summary 52 Chapter 2: Photon Unity Networking-The Chat Client 53 Differences between PUN and Unity Networking 54 Setting up PUN with Photon Cloud 55 Using Photonviews 57 Connecting to Photon and getting a list of rooms 58 Creating and joining rooms 61 Creating rooms 61 Joining rooms 62 Filtering results by user preference 63 Filtering arrays 63 Filtering and caching a room list 65 Automatic matchmaking 65 Finding friends 66 Syncing a level between players 68 Creating a chat client 69 The Connect screen 69 The Lobby screen The chat room 74 Adding friends lists 76 Summary 80 Chapter 3: Photon Server- Star Collector 81 Dedicated servers 82 Getting Photon Server 82 Creating a server application 83 Creating a class library 83 Responding to operation requests 85 Deploying the server code 86 Connecting from Unity and passing messages 8 Creating a game logic class 90 Assigning player IDs 93 Building a star collector game 96 Preparing the class library 96 The actor class 102 Sending an id to a player 104 Keeping track of the game state 105 Spawning and picking up stars 108 Broadcasting events 110 Connecting from Unity 117 lI Table of Contents Creating/destroying actors 120 Controlling the player 123 Summary 126 Chapter 4: Player. lo-Bot Wars 127 Player.O versus the Photon Server 128 Getting and setting up a development server 128 Setting up the Unity client SDK 129 Connecting to Player.O 129 Getting a list of rooms 132 Connecting to rooms 134 Creating rooms 136 Random matchmaking 138 Sending/receiving messages 139 Server-side code 142 orking with BigDB 143 Creating a simple rts prototype 146 The server-side code 146 The client-side code 156 Summary 168 Chapter 5: PubNub- The Global Chatbox 169 Overview of Pubnub 169 Getting started 170 How Pubnub works 171 Parsing JsoN from PubNub 173 Building a pubnub interface 74 Creating a global chatbox application 180 Publishing chat messages 181 Displaying chat logs 184 Summary 187 Chapter 6: Entity Interpolation and Prediction 189 Entity interpolation 189 The client-side prediction 190 Rigidbody simulation 191 Creating a networked object 192 Adding naive interpolation 195 Improving interpolation 197 Preparing for server authoritative movement 200 Implementing server authoritative movement 202 Notes on hacking 206 Summa 206 [ⅲi

...展开详情
试读 127P Unity Multiplayer Games
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
关注 私信
上传资源赚钱or赚积分
最新推荐
Unity Multiplayer Games 9积分/C币 立即下载
1/127
Unity Multiplayer Games第1页
Unity Multiplayer Games第2页
Unity Multiplayer Games第3页
Unity Multiplayer Games第4页
Unity Multiplayer Games第5页
Unity Multiplayer Games第6页
Unity Multiplayer Games第7页
Unity Multiplayer Games第8页
Unity Multiplayer Games第9页
Unity Multiplayer Games第10页
Unity Multiplayer Games第11页
Unity Multiplayer Games第12页
Unity Multiplayer Games第13页
Unity Multiplayer Games第14页
Unity Multiplayer Games第15页
Unity Multiplayer Games第16页
Unity Multiplayer Games第17页
Unity Multiplayer Games第18页
Unity Multiplayer Games第19页
Unity Multiplayer Games第20页

试读结束, 可继续阅读

9积分/C币 立即下载