How To Make A Game With Unity Multiplayer Netcode | Player Controller

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on everybody this is del mar and welcome back to my channel so in today's video i'm going to continue working on netcode for game objects which is the new unity multiplayer solution i'm going to show you how we can get additional features that i'm going to build upon the previous video where i show you how to add basic functionality to a multiplayer game so in today's video we're going to be adding a lot more to that we're going to be looking at network variables how to use a new type that we're going to be creating to store the player's name so we're going to be using the i network serializable class to do that and i'm also going to show you how we can control the player and basically synchronize the transformations of the player across multiple clients so let's jump into my computer and start working on it all right guys so we're going to continue on where we left off on the previous video which is to basically wired up the star hose start server start client also this network variable is going to be shared between the clients so we're going to be able to see how many players we have in the scene and i'm also going to show you the debug area and how we can basically log to that area and then we're also going to be implementing the ui manager which we're going to be binding to this we're also going to be looking at how we can basically show the player hud which means that we're going to have the player name basically as an overlay right above their head and then once you know multiple people join they're going to have basically their own player number or their player name so let's go ahead and get started by using the by looking at the ui manager so i'm going to go ahead and open that up and i already have the basically the skeleton here have a class inherits from mona behavior and then different buttons and also how many players we have in the game so we're going to be binding these as well so the first thing that i want to do because we're going to be using multiple screens is i'm going to be basically overriding the awake metals let's go ahead and do that and in the awake method i'm gonna do cursor that visible the reason why i want to do this is because these will make sure that i can show the cursor when i'm over multiple different unity sessions and that helps for you know if you're using if you're doing networking and have multiple screens i want to make sure that i select each each one of them so that i can basically move the player around and then what i'll do is i'll also do an update on the basically an override on the update meta and then i'll do the same thing on the star method here so we'll have awake update and start on the update i'm going to be updating obviously the how many players we have so i'm just going to do players in game text i will just do equal and then for now we don't really have the singleton that i'm going to need here but i'm just going to say that we're going to have players in game and then we're basically gonna show how many players we currently have so it's gonna be players and we have player manager and then instance and in the player manager instance we're gonna have players in game and this is going to be what's called a network variable and i'm going to show you how we can implement that for now it's not going to compile because we haven't really worked on the players manager so think of the players manager as a lobby is basically going to keep track of all the players that are joining in and i'm going to be counting okay if you're joining in in a session i'm going to count you as a player and then basically we're going to be incrementing the variable the same thing if i were to close the unity application we're gonna be basically decrementing a counter so we'll come back to this just make sure that you know you know you you write that down because that's what we're gonna do there and then the next thing is gonna be basically wording up the start button the hose and the client so let's go ahead and start with the install client button we can do let's do the host because that's going to be the the most important one and then because without the hose or without the server we're going to be we're not going to be able to have a networking game and then i'm going to be using lambdas in here i'm going to be lazy and create methods this is going to make it a lot easier and then what i'll do here i'll just duplicate this three times and then we'll just change these two so i know it's going to be the host the other one is going to be the server and then the last one it's going to be the client so we have basically i don't click event that it's going to be executed when we press the button and then we're going to have some logic inside so the logic is going to be fairly simple we're going to say network manager and if you look at it we we don't have it because we haven't really added it so if i hit control period we'll bring in the namespace which is going to be the unity that make code going to be using that a lot in these videos so and then this implements a singleton pattern so i'm going to be accessing that with the singleton property and then once i do that i'm going to have access to a lot of different things you're going to see that i have here the host so i'm just going to say you know what we want to start the whole so that's basically what i'm going to do here and then i'll just do an else and i'm going to do the same thing here with these ones i'm going to do this one is going to be the server and this one it's going to be the client so in the server we're going to start the server so we're going to call the star server meta and then in the client i'm just going to say start line so that's good and all but it doesn't really show us what's doing anything and the reason for that is because we haven't locked anything so what i'll do here i'll just say i have an implementation of a logger and that's also in the repo so it uses a singleton pattern and it basically writes to the debug area of the unity game view which i just showed you at the beginning of the video so just know that i have these three different methods that i can call at any time so what i'll do here is if i get because it's going to be returning a boolean right if we look at the signature it's bull i start a whole so if the boolean comes back with the true value that means that the server started correctly if it comes back with the false the server did not start it well and in this case make sure that you write the proper one which is when it's going to be host started no the the server so okay so i don't do the same thing here hose could not be started and then i'll just go ahead and copy this guy here and it's going to be basically the same because here we're starting the server and then this one is going to be the client and we can do the same thing with the with the else statements and then yep i'm going to put it there i'm going to be testing it here in just a second and then i'll do the same thing with the with the client okay and then the last thing that i wanted to do here it was going to be also i want to know the idea of the person that is getting connected and i had it in here but i think the layer manager should be keeping track of you know who is connecting and what's their id so we'll come back to that and i'll add it in just uh just a few seconds but just know that these right now it's going to allow us to basically start the server so let's go ahead and test it out so i'm going to go back into unity it's going to compile now we should have everything bound and i did that because i went and this video is not to show you and teach you how to do ui so i didn't want to waste your time there so i have a ui manager and this is this script right here this game object here with you know the different buttons so each one of these button is going to be one of these ones and then when you click on it you know they're going to be bound to this and it's going to be executed so we can hit play to to test it out okay so once you hit play you're gonna see that i mean nothing is happening other than the the log enable has is displayed but if i were to start the host you're gonna see that we were actually able to basically create a start the host so that we can start serving you know the game to other clients and i used to be able to do that in the well actually i'm able to do that by also going into the network manager which is now on that on the don't destroy unload and you know that we have those buttons also here so i can go in and do a star hose store server store client so all we're doing right now is basically moving that implementation from you know happening on the network manager and also doing it on the canvas because i mean we're building a game we won't be able to see the inspector when we build the game so that's going to allow us to do that okay so now let's go back into the ui manager and let's focus on the player manager so on the player manager i want to explain a couple things in here so this is also using a single singleton pattern and on the singleton pattern i implemented my own and this is something that i've been using from the beginning and it basically uses this script and this script is going to create a single instance that it's going to only live in the basically the life cycle of the scene when the scene gets destroyed it's it'll die and you can change it if you wanted to do a do not destroy a load but for now we're just going to keep it simple and it basically inherits from network behavior and this used to inherit from mono behavior but i change it because this implementation here that we're doing today is basically to handle networking so what is the players manager going to do so in my case i want to keep track of how many players are joining the game i want to display that information on the ui so you guys basically we can see how cool unity is when it when it comes to synchronizing that information and i'm also going to be logging you know the id of each player so that we can also get that information so what we're going to do today is we're going to be able to basically what we have here we'll do a private and then i'm going to introduce you to network variables and you're going to you're not going to see anything unless you do control period i'll be bringing in the unity the net code and this is the implementation of netcode basically it's going to allow us to store information that can be synchronized across the network right a network variable is uh of type generic and if you look at it it takes t values so this is going to be basically structs it's going to be or native times like an integer like well i wouldn't say a stream because we're going to have to do something for the string but if you wanted to store a float if you wanted to store the score if you wanted to store the position of the player a vector three a vector two you can do that with the network variable when i keep it simple i'm just gonna do an integer here and what this is gonna do is gonna it's gonna keep track of the players in the game so i'm just gonna say players in game and then we'll just do new and then the semicolon at the end another thing that is also cool that i haven't really play around with you also have permissions right so when we're talking about networking games we have the concept of having a server we have a concept of having a client so we don't want to have the clients be able to obtain how many players are in the game because that will be kind of hacky right we we want to make sure the server is the one that has control of that so with this you can say okay who is going to have access to this variable is everyone that has access to writing and reading from the variable is it going to be only the owner so in my case it's just going to leave it as default we're just going to have the server be the one that is going to be the traffic cup of this and then the next thing that i'll do here i'll say players in game so it's going to be a property that we're going to be exposing because remember on the ui manager we're going to be displaying that information so we want to make sure that our property is going to expose that basically this value right here so we'll just do i get here and i'll just do get and then curly braces and then we'll just say return players but you can now return just players in game because the type is a network variable the type of this is an integer you need to do the value and that's going to give us a value that the network variable is a story and then the next thing that i'll do is we'll just do the star but the star meta and in the start method i'm going to do a couple of things i want to basically keep track of you know who is getting connected and to do that we're going to be accessing the singleton again so network manager and then it's not instance it's singleton and confused because i have my own implementation there's a couple methods in here that you can basically events that you can access you can say on client connected you do x on client disconnect that you do y on server started you do you know whatever you want to do so on this one we'll do on client connected it's going to be any vein handler right so you can do if you want to do this you can create your own meta and then basically do that i'm just going to i'm just going to do it the lambda way i use i don't know i just like to use those a lot and just keep it simple i can see what's happening without having to scroll down and then make sure that you don't do a parenthesis there so here what we're going to do is we're going to be basically making sure that the the one you know who is going to be writing to this variable as a server so there's a couple of properties in here you can say okay is this the server is this the client is this the host so in our case i want to make sure that we are the server so if we are the server i'm going to be basically incrementing these values so it's going to say value and then we'll just say plus plus gonna increment it you know plus one and then i'll do the same thing with the on disconnect i want to make sure that i decrement that because if we close the the player session i want to make sure that i'm decrementing so i just i'll just do on client disconnect call back and i'll do a minus minus instead of the the plus plus so we have incline connected as soon as somebody connects we're going to be incrementing this variable and well in as long as we're the server and then you know when somebody disconnects we're going to be decrementing this variable as well the other thing that i also wanted to do is i want to show you the well actually i was going to be logging in here just to make sure that i have the id so what we can do here just say logger instance and then log info and we can do something cool like you know id we're gonna say id just connect it and then semicolon and i will do the same thing here just to make sure that we can show that disconnected and then it's cool because you can see you know who is connecting who is it disconnecting and then also we're going to be displaying that on the ui so if we go back to the ui manager now and we go ahead and remove the the comments in here now we're going to have access to this it's going to be you know because this is an instance it's a singleton they're going to be able to access so we have players in the game we're going to be displaying that information and if we go back into unity and test it you know before we keep coding this is going to be this network variable i'm going to and i'm going to show you why you know how that is wired up and if you look in here there's going to be players in game and it's basically that if we go into the scene view and then hit f and let's change it to 2d you're going to see that that is bound to that so what we need to do now is we need to go into players manager and we need to add also a network object and the reason for that is because player manager is a instance of a network behavior if we go back into the singleton you're gonna see that i have a network behavior right so any object where we're going to have network variables are going to have to have a network object that way that information can be synchronized so that's going to be one of the dependencies so if we try this style and hit play we should be able to see that the if i click on host i should be able to see that we have one player in the game and we can see that we have the player in the game so that it's going to you know increment and decrement as players get connected i can also see in here on the top left side that you know player zero just just connected and we also have the you know the whole started so let's go ahead and hit play to stop it so now we're gonna do we're gonna go into the player hud which is going to be an overlay that we're gonna be putting on the player and that way we know the player's name but when you when i started working on this i wanted to do you know network variable and i wanted to do something like this and basically it's going to say player's name and then i can do new and then and then do that so i did that and i'm like why is this not working why is it not taking a string and the reason for that is because natively they don't support a string unless you basically do a different implementation on on a specific type that is going to inherit from a class that i'm gonna that i'm gonna be showing you so what we need to do to basically support this is we need to create our own struct and the way that it's gonna work i'm gonna call this the network a string and we need to inherit from i network serializable so and we will have it in here we'll basically do that and this is going to allow us to basically just do this right it's going to it's going to allow us to implement a network string but we need to tell you how to do that so to do that we're going to do a private and we're going to tell it what type we're going to be storing so we're going to do a fix a string and it's going to be 32 bytes and this is going to be basically storing or strain information then what we'll do is we'll do public void and we need to say network actually before doing this i think it'll be easier if i just hover over this and then look at the implement interface and it's going to give us the entire signature just didn't want to type all that and then also just to make sure that we you know we have it correct so and then i'll do serialize value and we'll have to pass in the the actual reference of the info type so what's going to happen is it's going to run its own serializable and it's going to pass that information to the network behavior we're going to be able to store the network variable as a network string so this is just you know using serialization and this realization and then what i'll also do is i'll do an override of the tostring method here and then we'll just return the info just to info and then to a string and then there's also a couple of operator overwrites that we need to do and i'm just going to copy them from the implementation that i got from the documentation and i'm not going to go through it because this this works but just know that we're creating our own type if you wanted to store a different type maybe this is too big for your own implementation then you know you can change it there's also other types in here that you can do so there's fix stream 4986 512 and a lot of different types that we can that you can extend there's also other types for network variables that they come out of the box i'm not going to cover them today but i'll cover them in the near future okay so now that we have these what i'm going to do is i'm going to go ahead and move this out and move it to share because we're going to be using this quite a bit it's going to create a new file and the file is just going to be the network string so just say network the stream just to keep things clean and organized and i'm not going to do an in-space and i'll just remove the usings there and then we'll just bring in all the indian spaces necessary we also need that from unity collections it looks like everything it's good now so if we go back to playerhot we should have everything working and looks like it is so now we need to do is we need to actually implement this thing right so i'm going to go ahead and create a new bull variable that is going to basically store whether we already set the player name or not that way we don't keep doing it over and over and i'll show you how how that works so and then i'll do public override and this one is going to be on network span so this is going to be one of the core methods that we're going to start covering so if i go into network behavior do an f12 you're going to see the implementation in here there's a lot of things in here i think if i just do and look at the methods you're going to see a bunch of properties we have also different methods so on network dspan that's going to happen when we you know basically where we're destroying the the instance and of the actual spawn player object and we also have the on network expand so i'm going to be basically wiring wearing those up because we're gonna need to know at what point that network the player is actually getting expand so that we can intersect it and then basically set the the overlay so what i'll do here is i just want the server to be able to do this i'm just gonna do if it's the server then we're going to basically set the value so i'm gonna say player name that value is going to be equal to and we're just gonna do player and then here i'll just do honor client id so it's going to be basically setting the value of the player name based on the owner client id the other thing that i also wanted to do is this is going to set it but there's times when this is now set at the appropriate time so i could basically get the overlay the the overlay of the player which i'm going to show you where it is and i'll show you that a little bit on the previous video so if we go back to and wait until this loads go into prefabs double click on the player and we go into the scene view you're gonna see that i have this overlay in here right it just says info and that information is stored in a canvas and there's a background which is basically the back the black area here i'm going to make the gizmo just a little bit smaller so we can see it and then also the player e4 is just basically a text box so what i need to do is i'm going to basically set that right because we want to set the text box based on the player's name so what i'll do here also just create a new method just going to say set overlay and then it's going to be called from the from the update method but i don't want to call it over and over and over and that's why i added this property right here so i'm going to say local player overlay and then i'll just say the game object which is going to be this game object and i'm going to get the get component in the children and then the game component in the children is going to be a text mesh pro make sure you type that right that right text mesh pro and i believe that is you guy i hate that name i don't know why his name that way but anyways i always say that on every video and and then what i'll do here i'll just say text and then it's going to be as easy as just saying you know i just want to get the value of that property and here i know i don't want to do any checks because the well actually is going to be a string so we don't need to do interpolation so i don't need to check to whether this is a server or not because it's going to be a readable network variable so we can just access that from anywhere so but right now we haven't really set it we just have a method so what i'll do here is i'll just access the update method and in the update method i'm just going to make sure that i haven't you know i haven't already set the overlay so you'll say and also i want to make sure that the the player's name which is going to be the the player's name that value is not null or empty so as long as it's not all empty and we haven't set it we're going to basically you know basically set it so i'm just going to call the set overlay and then there we go so that should basically cover let me make sure that i so let's just basically cover having a network variable that is of type string we're going to be creating we created a property to basically determine if we set it or not and make sure we don't keep setting setting this over and over so we may want to make sure that we say this is equal to true so if we already said it there's really no reason to set it against it's going to be false and then we're going to be basically quitting the basically the update method okay so that's cool and all but what does that give us well let's go ahead and check it out let's go back into unity and then i'll go back into the main scene we'll hit play and see what we see now on the overlay and before we hit play let's make sure that we attach the script as well to the player object so i'm just gonna do the player hud and that's gonna make sure that we have the implementation that we just added let's go back hit play and then we should see that it shows the overlay and we're gonna do a star hose and you can see that we now have player zero joining we should also see zero just connected just like we had before so let me actually change the resolution of these just so that we can see these a little bit bigger there we go so we can see more information and you know as we're playing the scene so the next thing that i want to focus on is going to be the player control so if we go into the player control we're going to be creating a player control so we can actually move the player for now it's just going to be boring it's not going to have animations but it's going to move forward backward left or right so let me go ahead and create a new variable it's going to be a serializable so we can update the speed and make sure that you type that correctly serialize fill and then control period and then it's going to be basically the workspace just to walk speed and i will set it by default to 3.5 that's a value that i tested with and then i'll do another serializable field this is going to be a vector 2 and this is going to be basically the default position of the player on the on the plane so it's going to do default position range and then i'll set it to a value that it doesn't go beyond the bounds on the plane so just do negative four comma four and then we also do a couple networking variables in here so just do private we'll do a network variable this one is going to be one that is out of the box so we're just gonna have a flow this one's gonna keep track of the player forward and backward and back position and then i'll just do a new so these are cool because you don't really need to do any extra experimentation it's just you know available there now let's go ahead and copy these we also need one for if i'm moving the player left to right so it's going to keep track of that it's going to keep track of the other direction and i also want to keep track of i want to cache the the values of the client that way we don't keep updating if there's no changes so i'm just going to do two different two different variables for that so it's going to say client caching and then here i'll just do private and this is something that i was just playing with i mean there's a million ways to do this and i'm just gonna call this one all and then i'll do the same thing with the other one and this one's going to be left or right we're going to say left right i think just to keep this consistent so now on the star method this is the one that is going to that we're going to use to position the player so i'm going to say player will actually transform because this script is going to be attached to the player and i'm going to say new and it's going to be a vector 3. i'm going to use the random and then range and the range is going to be from the default x comma default position y so basically from negative four to four and then the y axis i don't want the player flying around so i'm gonna keep it keep them at zero and then i'll just go ahead and copy this as well because we're gonna be also randomizing the position of the z-axis so that's basically what that's going to do it's going to keep it you know it's going to keep the player between negative 4 and 4 on the on the x-axis and then on the on the c-axis is going to be basically from that same range make sure you name this correctly otherwise it's going to is going to collide with this okay so that should basically position the play randomly and then we'll also do is i'm going to have a method in here that we're going to have to call from the server so i'm going to say update server and then here we'll just have curly braces and then i'm just going to say transform that position and again we're going to do a vector3 this one is going to be a little bit different because we want to be incrementing the value of the of the x-axis so i'm going to do a position that x and i'm going to grab in this case it's going to be the left and right position right because we're looking at the x-axis and then it's going to get the value of that so remember this is the value that we're going to be reading and it's the networking value and then the transform position at y is not going to change so it's going to do that and then we'll do the same thing with the basically with the z-axis just copy and paste these but this is going to be except it's going to be z and remember it's going to be forward and backward so i'm going to change that and cool that it's cool but what else right okay let's go ahead and keep implementing this and okay so i'm gonna do void private void and this is gonna be update client client is gonna do the majority of the work because we want the client to keep track of basically the claire is the player so he's going to be or she is going to be sending the changes on the x-axis or the z-axis so what do we do to do that well we need to keep track of a couple things so i'm going to keep track of the 4 and backward and it's gonna be set to zero it's gonna be basically a couple of local variables that i set in here and i'm gonna do left right and i'm also going to be setting it to zero and what i'm gonna do is i'm gonna be using the input and yeah this is gonna be the all input system but we're not talking about input system today so we're just gonna just gonna use the the simplest one for now and i recommend you looking at the new input system because it's better for cross-platform support but for now because we're just doing a prototype this is not what we're covering we're just gonna do do it this way okay so i'm just gonna basically do my my w2 or the up arrow to basically go forward and then i'll just go ahead and copy these let's see one two three four times so we can go in different directions and this one's gonna be s this one is going to be down this one is going to be my a this one is going to be left and left arrow and then i'm going to do right arrow and i'm going it's low i don't want to basically well i'm probably going fast but i don't want to go also too fast so that you don't understand what i'm doing it is going to be going to be b so basically all the different directions so once we have that we need to basically tell the system okay what is it that we're going to be updating well if we go forward i want to update the variable which is going to be my forward and backward and it's not going to be this one it's going to be the one that i have in here forward backward position so make sure that you update that and then remember we have a walk speed so i'm just going to update it to that but we can't really access that directly this way and i'm going to show you why because remember this is the client the client has no access and even though you could do something like this and this is proper it's going to throw an error and say you don't have access to this network so what we need to do instead is we need to keep track of that in a different variable which is the local variable that i have above it and i'm going to say this is going to be you know greater than sorry a plus or equal to work speed this one is going to be you know we're going we're going on the opposite direction so this is going to be minus or equal and then for left and right i'm going to do the same thing left right this is going to be if we're going well it's actually going to be minus because we're going on the negative on the negative position of the x-axis so it's going to be that and then i'll do the same thing in here just want to make sure that i don't i'm not making mistakes but regardless if i make any mistakes it's going to be in github and you guys can look at the the final version so now that we have all of those set we really really haven't updated any network variables so that's what we need to do here so what i'm going to do is i'm going to say okay if the all forward position does not equal to the new forward position then we want to make sure that we obtain the the server with the new options and then i also want to do the same thing with the old left right that's not equal to the left right position that way we don't keep doing this on every single frame so just trying to keep you know keep that in mind and then we're getting an error here let me see why we're getting an error and this is not a left and right position it's going to be left and right also make sure that we set it so that we can keep you know we don't keep running this on every frame so it's going to be forward and backward and then this one is going to be all left right position is going to be to the new new left right position okay so that should be good and then we need to basically update the server hey how do we do that well we need to create a new method and that method is going to be update client position server rpc and this part right here is surprisingly very important if you don't need name this method this way with the suffix or server rpc it's actually going to complain so make sure you keep that name in mind whenever you're creating a an rpc call and rpc stands for remote procedure call which means that the client is going to be making a call on the server and then it's going to be this is going to be forward backward comma i'm going to be also putting passing left and right and well this is going to be the implementation right we don't want to do that here it's actually going to be this and it's going to be there right now it's not going to like it because we haven't really implemented it but i have it in my clipboard because i use meta typo and then we'll just do curly brace and then here we're going to be i'm going to be introducing you to the server rpc attribute which is basically telling the networking system that we're going to be executing this method on the server side i'm going to call it from a client but this is going to be executed on the server well who is the server the server has the power the server can update these variables so that's basically what we're going to be doing just updating some of those variables so what i'll do is i'll say forward backward position which we now have access to is going to be equal to the forward and backward value that i'm passing in and i'll do the same thing with the other one left right position it's going to be equal to left right there's probably better names to these but i mean to be honest this makes sense to me in my head so hopefully it makes sense to you as well so this is cool and all but we haven't really called the update server or the update client in fact visual studio is telling us we're not using it yet so we'll just do that on the update method and i'm also going to be introducing you to two different properties and i think i already mentioned them but one of them is server and then i'm going to say the other one is going to be is client which we haven't used yet i know i mentioned it but i we haven't actually used it so obviously on the x server we're going to be calling update server which is going to read the values of the server network variables and i shouldn't call it server network variables i should call it network variables because they're accessible from you know any client you just can't write from any of the clients unless you tell everybody basically the variable to do so but anyways now we can do update client and that should be everything that we need to do to be able to update the position from a client to the server but remember we never actually added the player control so let's go ahead and go back into the the player prefab we're going to be adding the player control here and we should have the walk speed we should have the full position and also our network variables in here so we should be able to hit play now and see it running as we coded it so we can hit star host and for some reason it's out of this world and i think it's because this value is way too high let's go ahead and do 0.1 start with a a small value and i'm going to hit play let's see if that it's a better value star host and we can now see that my value of 3.5 was was to was too large i think i'm gonna make it let's do 0.05 and then we can go back in here and then hit play and make sure that everything everything still works so i'm going to go ahead and start the hose and we can move our holes and i can move it around okay so now let's make something cooler right we want to make sure we can test this and run it as uh basically as a build so i'm going to go ahead and build it really have a build folder select that folder build it and then i'm gonna open a bunch of sessions and we'll see it running all the different players at the same time all right guys so i just realized that i had an error and i was able to update the position of multiple clients so there's another check in here that we need to do so we can't just really rely on just each client because we got multiple clients right we want to make sure that we can only update the clients where we are an owner so i'm going to say okay if this is a client and i'm the owner i'm going to basically control that client otherwise it won't really make sense you're going to be controlling other different players we also need to update the player amateur so if we go back into it and we should have have a network object a player hud and also a player control we also need something new which is called the player the network transform and if we don't have these we're not going to be able to basically change the transforms of the player and basically synchronize it across different clients so these components allow us to synchronize the position the rotation the scale the threshold the angle scale threshold as well basically different you know transform information that gets synchronized across the network and it's actually really really cool so once you add it you're gonna see the changes so now that we need that let's go ahead and build it and test it out all right so i went a little crazy and added a bunch of different sessions so i'm gonna go ahead and start the hose we can see that the player is now here i can move it around let's go ahead and try this one over here i should be able only to move this one i cannot move the other player and that's what's happening you can see it's synchronized here also the players in game updated so what i'm going to do is i'm going to go ahead and start every single one of them and i want you to pay attention to the players in game as it updates i'm starting the client there starting the client here starting the client here and then now we should have a bunch of so if i wanted to move these when i can if i wanted to move this one i can let's bring this one closer i don't know which one is which but you can see that everything is is updated right in real time i can also move this one and i'm clicking over every single one of them and we currently have 12 different players let's try and go into unity and then also create a session in unity i want to show you how everything shows in real time and i'll show you that a little bit on the previous video but i think it's cool to know that that it's one of the advantages you can see that all my players my network players are showing here you can also go into the scene view we can see you know everybody it's currently being synchronized and the cool thing with this is i can also grab one of these windows and say that i wanted to move and i can see these you know changing in real time as i'm pressing the wads keys and i can move it around this is player player six and if i wanted to pick a different one we can do perhaps this one this one i don't know which one it is oh there we go it's hiding we can just put it put it right here and again if you want to you know change one of these ones and look at some of the properties why are things not working you you know you get the power of unity to be able to see all that so if you like this video make sure that you subscribe because it's going to help me in bringing you the next video which i'm going to start working on it today i'm going to show you how to synchronize network animations also how to create a lobby how do we accept players and and so on there's just a lot of features so make sure you subscribe and also hit the like button and notification bell because it's going to help me you know in letting you know when the videos get released so that's everything that i have for today thank you very much guys
Info
Channel: Dilmer Valecillos
Views: 5,679
Rating: undefined out of 5
Keywords: unity multiplayer, unity multiplayer tutorial, unity multiplayer 2020, unity multiplayer 2021, how to make a multiplayer game, unity multiplayer game tutorial, multiplayer networking, unity multiplayer game development, how to make a multiplayer game in unity, new unity multiplayer, new unity multiplayer system, netcode for game objects, unity netcode tutorial, setup netcode, network manager, photon 2, photon2, multiplayer game dev, beginner, unity networking 2021, unity unet
Id: rFCFMkzFaog
Channel Id: undefined
Length: 40min 0sec (2400 seconds)
Published: Mon Nov 15 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.