Multiplayer unity

Páginas: 18 (4387 palabras) Publicado: 11 de marzo de 2012
Unity Multiplayer Tutorial
For using Networking in Unity. Author: Andrius Kuznecovas Last Revision: 24-MAR-2010

Contents

1. Multiplayer Tutorial
1. Introduction
2. Getting Started
3. Creating Your First Client / Server Application
3.1 Preparing Scene
3.2 Creating Scripts & Adding Components
3.2.1 Server & Client
3.2.2 Scene & Objects Instantiation On The Network
3.3 QuickOverview
4. Implementing Multiplayer in Startrooper
4.1 Changing Scene
4.2 Integration
4.2.1 Integrating Objects & Scene
4.2.2 Server & Client
4.3.3 Final Polishing
4.3 Quick Overview
3 3 4 4 5 5 8 10 11 11 11 11 21 37 38

Multiplayer Tutorial
Welcome, Unity User. Here you will learn advanced usage of Unity Networking. Have a great time and we hope that this tutorial will behelpful.

1. Introduction
The aim of this tutorial is to show the essence of Unity Networking. We will show how to create basic and advanced network applications using Master Server/Client, UDP Server/Client and Direct Connect. In this tutorial we will use Unity iPhone 1.6, iPhone 3GS and the StarTrooper demo from the Unity web site.

2. Getting Started
There are a few things that you shouldknow before you start. • You will learn how to: Use basic and advanced components of networking. Create a server and client. Use the Master Server. Use Direct Connect. Use UDP Broadcast Server. Create a simple scene on the network. Convert the StarTrooper game to multiplayer.

Use other Unity components and more. • You should have: Unity iPhone 1.6. iPhone or iPod. Knowledge about networks andhow they work. Advanced C# and JavaScript skills. Basic Unity skills. You can find more information here.

• Important notes: Unity supports .NET 1.1 and 2.1. You can disable or enable Networking in: Edit -> Project Settings -> Player -> Enable Unity Networking. Unity Networking supports wifi, 3G and GSM connections. You can connect between different types of Unity targets. For example you canconnect from Unity on the desktop to Unity iPhone, from Unity Web Player to Unity iPhone, etc.

3. Creating Your First Client / Server Application
In this chapter, we will cover the basics needed to create a simple multiplayer application. We will create our first example featuring moving objects on the network and basic handshaking between the client and server. The example uses all basicmultiplayer components such as: Network and NetworkView. We will use Direct Connect for connection between client and server.

3.1 Preparing Scene
• Now let’s start with a simple scene. Your first steps: Create a new Project. Create a new Prefab and name it Player: Assets -> Create -> Prefab. Create a new Cube GameObject: GameObject -> Create other -> Cube. Drag your Cube from the Hierarchy to your PlayerPrefab in the Project and then delete your Cube from the scene.

4

Create a new Plane and name it Ground: GameObject -> Create other -> Plane. Your Plane parameters should be: Position (0,0,0), Rotation (0,0,0), Scale (5,5,5). Create a Directional Light: GameObject -> Create other -> Directional Light. Light parameters: Position (0,15,0), Rotation (25,0,0), Scale (1,1,1) Shadows -> Type ->Soft Shadows. Finally, save your scene and name it MainGame: File -> Save Scene. Everything should look like this image:

3.2 Creating Scripts & Adding Components
• Next you will learn how to create the server and client, instantiate the scene and objects on the network, move objects, and connect everything together.

3.2.1 Server & Client
• We will start with the most important — thecreation of Server and Client: Create a new JavaScript file and name it ConnectionGUI: Assets -> Create -> JavaScript. Add this file (by dragging) to the Main Camera object in the Hierarchy, then open the file and create some variables:
var remoteIP = "127.0.0.1"; var var var var var remotePort = 25000; listenPort = 25000; useNAT = false; yourIP = ""; yourPort = "";

5

Now we will create an...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • unity
  • Unity
  • Resumen Unity
  • Unity Bank
  • unity temple
  • unity temple
  • San Andreas Multiplayer
  • Unity

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS