hi guys i'm popsy and this is episode one in working with multiplayer using fishnet in unity so the first thing that you want to do is you want to go to fishnet on the unity asset store you want to go find fishnet and you want to add it to my assets you've got to make sure that you're logged in also just for a quick reference if you scroll down the link for documentation is right here which is really useful if you're facing issues you just want to read out more on how it really works but other than that you should be able to follow this guide and it should work just fine now when you are back in unity you can go to the package manager find my assets in here you should be able to find fishnet networking and you should be able to just click import and we're just going to import everything now once you're done importing it you will see added fish networking defines to player settings and default prefab generator update so now you can see that we have this fishnet folder right here and let's open up this and go to example and prefabs and you'll find this network manager prefab we just drag this into our scene and this is actually pretty much the net basic networking setup now this will also include a canvas which will be able to enable whether you want to join as the client or the server and you can see that's the canvas that's under the network manager but in the network manager you'll be able to see there's a player's spawner script already attached and you also need some spawn points so let's just first of all make those spawn points so i'm just going to make a parent object called world and let me just make a plane which is going to be the ground just going to make sure world is centered and i'm just going to make a quick folder for materials and a quick folder for scripts and a quick folder for prefabs and in materials i'm just going to make a material for the ground and i'm also going to make a quick material for the player now under the world i'm also going to make a parent object for the spawn points and i'm just going to in here define the spawn points one point just going to put it above the ground and i'm just going to place them in some different spots here that should be enough if we go to networking manager we can then just drag down the spawn points here to add them to the list of small points and then we don't have to look anymore these now we need to set up the player so i'm just going to make a an empty actually and just call it player and under that i'm going to add a capsule and call that body this is because i like to be able to differentiate them from one another now let's send to the player put him a little bit above the ground and i'm just going to make it a player controller or sorry a character controller um with a script that i am just going to call player control i'm going to add that script to the player like so and i'm going to open up the script now i already have a script that is set up ready for multiplayer but i'm of course gonna explain to you what part of it so this is basically just my sort of base setup for a multiplayer project for a character controller movement now there's only a few things that are actually really important the first thing is you're using fishnet. connection and fishnet. object these are pretty much your main two imports now the class instead of monobehaviour is going to be network behavior and you'll need this for every script that's going to interact with the network and the last thing that's important is that at least the way that i do it is i don't like to spawn multiple cameras i feel like that's a mess so instead i actually only just hold the main camera and i make sure that i set the main camera to our own local player so each local player will grab the main camera and set it as his own so that way there's only ever instantiated one camera now the way that i do this is i make sure it happens as soon as we start the server which means it's actually before the start function this is done by writing public override void onstart client and then in the beginning of this you need base.
on. client this is just a very basic setup of this and then in my case i've just done if bass is owner which means if we are if if we are on the character right now that we are the owner of we want something to happen which in this case i've set the player camera which is something i've defined up here to be equals to camera. main because that's the only camera we have i set the player camera transform position to a transform that i actually set up in my script idea i don't think i saved it so as you can see here i've just set up some base values as well in the script that is already there which are the ones i found working for me now let me just apply the material for the player on him and let's also for that sake just put on uh some vices which is something i like to be able to see which direction he's looking it's going to make this 0.