Character Selection from a lobby in Unity

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Introduction to ReportSmith and Effective Dated Tables
Pong! “The oldest commercially available game in history” Resources created from the video tutorials provided by David Phillips on
Introduction to C# Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
GameCamp! and Game Davis Introduction to Unity®
GameCamp! and Game Davis Introduction to Scripting in Unity®
Customizing Word Microsoft Office Word 2007 Illustrated Complete.
HELLO WORLD: YOUR FIRST PROGRAM CHAPTER Topics  Hello World?  Creating a Unity Project –The Unity Project Folder  MonoDevelop: Unity's Code Editor.
Based on Roll-a-ball video tutorial from Unity Technologies Part WakeUpAndCode.com.
Unity 3D game IDE 1.  Unity is a multi-platform, integrated IDE for scripting games, and working with 3D virtual worlds  Including:  Game engine ▪
by Chris Brown under Prof. Susan Rodger Duke University June 2012
UFCEKU-20-3Web Games Programming Unity 3D Basic Concepts Using and Creating Prefabs.
EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 13 Wenbing Zhao
Web Games Programming An Introduction to Unity 3D.
UFCFS D Technologies for the Web Unity 3D: Review of Topics and Related Concepts.
Quiz Me Tutorial. Introduction QuizMe is a trivia game (the example uses baseball) you can use as a template to build quizzes on any topic. The user steps.
Unity 5 Visual Studio Code * Asset Store * FPS * Terrain.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
Learning Unity. Getting Unity
Level 1 Tutorial Project How to put a movie player on your Weebly website using an HTML code.
Videos. Adding Videos to a Web Page Videos can make our pages more interesting and engaging. Most video-hosting services, such as YouTube, will provide.
SE 320 – Introduction to Game Development Lecture 3: Unity’s Interface and Concepts Lecturer: Gazihan Alankuş Please look at the last two slides for assignments.
UFCEK-20-3Web Games Programming Unity 3D: Review of Topics Publishing for the Web.
Videos, the More Tag, Permalinks, and Shortlinks.
Select (drop-down list) Inputs. Insert/Form/List Menu.
CIS 234: Java Methods Dr. Ralph D. Westfall April, 2010.
Tutorial 3 Creating Animations. XP Objectives Learn the different elements of animation Create frames and layers Organize frames and layers using the.
XPages Example: Generating Dynamic Editable Fields from a Document Collection Author: John Mackey Groupware Solutions Inc.
GameDevClub CODE CHEAT SHEET NOTE: ALL OF THE CODE IS CASE-SENSITIVE AND THE SYNTAX IS STRICT SO A LOT OF YOUR ERRORS WILL PROBABLY COME FROM TYPOS If.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
UFCEKU-20-3Web Games Programming Instantiating World Objects.
UFCFSU-30-13D Technologies for the Web An Introduction to Unity 3D.
Expressive Intelligence Studio // Center for Games and Playable Media // Unity Pro John Murray Expressive.
 Motion Tween allow us to move a shape on the stage from one place to another.  In order to use motion tween, the shape to be moved must be converted.
Tutorial 3 Creating Animations.
EEC-693/793 Applied Computer Vision with Depth Cameras
Quick Intro to Unity Lecture 2.
Millennium Create Lists in Action
3GB3 Game Design Unity 3D Basics.
More (C#) Scripting Day 2, Lesson 1.
Teaching Characters to Walk: Learning Methods, Part 1
EEC-693/793 Applied Computer Vision with Depth Cameras
Videos.
Unit Lessons Work with actions
EEC-693/793 Applied Computer Vision with Depth Cameras
Unit I: Developing Multipage Documents
More elements 10 Basic elements.
Word Tutorial 3 Creating Tables and a Multipage Report
Unity 2D: Step by Step, Part 2
lecture 8 Our First Project
Introduction to TouchDevelop
This presentation has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational purposes.
This presentation document has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational.
Making Objects Move in Unison: Using Lists
Create a Simple UI Game in 10 Steps
A beginner’s tutorial for Unity and VR
Player preferences, Loading Scenes, Activating and Enabling
ROOM 2+ FEATURES A-CREEPIN’ BEFORE WE START: LANYARDS RECAP ALL HERE?
lecture 9 Our First Project
Using Templates and Library Items
Videos.
Myo + Oculus Rift Tutorial
Image #1 Getting Started
Reports and Forms Second Term,
EEC-693/793 Applied Computer Vision with Depth Cameras
Making Objects Move in Unison: Using Lists
Unity Game Development
This presentation has been prepared by Vault Intelligence Limited (“Vault") and is intended for off line demonstration, presentation and educational purposes.
Unity Game Development
Presentation transcript:

Character Selection from a lobby in Unity

1) Set up 2) Add Overview 3) Add 4) Update Set up lobby scene and change Lobby Player Prefab Overview 2) Add Add code to LobbyPlayer.cs 3) Add Add code to LobbyManager.cs 4) Update Inspector slots for lobby and lobby player

Set up Lobby scene and lobby Player Prefab 1 Set up Lobby scene and lobby Player Prefab Add Duplicate scene, import lobby from asset store, drag in lobby prefab to new scene, add scene to build Add Duplicate the Lobby Player prefab – add to scene Add Add the three Player Avatar buttons – apply and delete from scene Modify Set up the Lobby Manager Inspector with the scenes and the game player prefab and other settings Move Move/shrink the name field, drag buttons into place

Add the three Player Avatar buttons to the Lobby Player Prefab 1 Add the three Player Avatar buttons to the Lobby Player Prefab Make a copy of the lobby player prefab (edit – duplicate) Drag copy into scene Drag avatar buttons into prefab Apply Delete scene version

Update Inspector for Lobby Manager Prefab 1 Update Inspector for Lobby Manager Prefab Add Scenes Add New LobbyPlayer Prefab And default Avatar

Change the layout of the existing Elements in the player list 1 Change the layout of the existing Elements in the player list Start the lobby in play mode Switch over to scene tab Make the name field smaller Copy the rect transform component Leave play mode Paste component values into rect transform in prefab Repeat for buttons

Add code to LobbyPlayer.cs 2 Add code to LobbyPlayer.cs Buttons and Avatar Index Variables For each button – call the avatar selection method Button Listeners Case statement and rpc/command call Avatar Selection Method to change a line in a dictionary in Lobby Manager Rpc / Command

LobbyPlayer.cs code changes - variables 2 LobbyPlayer.cs code changes - variables public Button player1Button; public Button player2Button; public Button player3Button; public int avatarIndex = 5;

LobbyPlayer.cs code changes – Button Listeners 2 LobbyPlayer.cs code changes – Button Listeners Inside SetupLocalPlayer() player1Button.onClick.AddListener  (delegate {AvatarPicker  (player1Button.name);}); player2Button.onClick.AddListener  (delegate {AvatarPicker  (player2Button.name);});              player3Button.onClick.AddListener  (delegate {AvatarPicker  (player3Button.name);});

LobbyPlayer.cs code changes – AvatarPicker() 2 LobbyPlayer.cs code changes – AvatarPicker() void AvatarPicker(string buttonName) { switch (buttonName) case "Player1": avatarIndex = 0; break; case "Player2": avatarIndex = 1; case "Player3": avatarIndex = 2; } if (isServer) RpcAvatarPicked (avatarIndex); else CmdAvatarPicked (avatarIndex); I added this directly after setuplocalplayer()

LobbyPlayer.cs code changes – Rpc / CmdAvatarpicked 2 LobbyPlayer.cs code changes – Rpc / CmdAvatarpicked [ClientRpc] public void RpcAvatarPicked(int avIndex) { CmdAvatarPicked (avIndex); } [Command] public void CmdAvatarPicked(int avIndex) { LobbyManager.s_Singleton.SetPlayerTypeLobby(GetComponent<NetworkIdentity>().connectionToClient, avIndex); } I added this directly after avatarpicker()

Add code to LobbyManager.cs 3 Add code to LobbyManager.cs Set up and initialize dictionary Variables Add dictionary entry for each lobby player in OnLobbyServerCreateLobbyPlayer Modify Method SetPlayerTypeLobby – called by Lobby player to set the avatar index to the correct dictionary entry Add Method Override OnLobbyServerCreateGamePlayer - called when the lobby player is being turned into the game player – pass the correct avatar from spawnprefabs list here.

LobbyManager.cs code changes - Dictionary 3 LobbyManager.cs code changes - Dictionary Add to class: public Dictionary<int, int> currentPlayers; Add to Start() method: currentPlayers = new Dictionary<int, int>();

3 LobbyManager.cs code changes – Add dictionary entry for each lobby player if(!currentPlayers.ContainsKey(conn.connectionId)) currentPlayers.Add(conn.connectionId, 0);

LobbyManager.cs code changes – Add Method SetPlayerTypeLobby() 3 LobbyManager.cs code changes – Add Method SetPlayerTypeLobby() public void SetPlayerTypeLobby (NetworkConnection conn, int type)         {             if (currentPlayers.ContainsKey (conn.connectionId))                 currentPlayers [conn.connectionId] = type;         } I added this right after OnLobbyServerCreateLobbyPlayer()

LobbyManager.cs code changes – Add Method SetPlayerTypeLobby() 3 LobbyManager.cs code changes – Add Method SetPlayerTypeLobby() public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)         {             int index = currentPlayers[conn.connectionId];                 GameObject playerPrefab = (GameObject)GameObject.Instantiate(spawnPrefabs[index], startPositions[conn.connectionId].position,Quaternion.identity);             return playerPrefab;         } I added this right after SetPlayerTypeLobby()

Update Inspector for Lobby Manager Prefab 4 Update Inspector for Lobby Manager Prefab Add New Avatar prefabs

Update Inspector for Lobby Player Prefab 4 Update Inspector for Lobby Player Prefab Add Player Button Prefabs

Thanks For Watching! Thanks to the blog entry on Les Jeux Videos: http://abrgame.blogspot.com/2016/01/using-unet-to-spawn-different- player.html And to Khalil and Ajay for watching my tutorials and leading me to the above blog post. Jill@RogueDuckStudios.com