Making a Multiplayer FPS in Unity (E09. Player Model) - uNet Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
thanks for tuning in at brakus hello and welcome to video number nine on making a multiplayer FPS in unity in today's video we're going to take a look at adding some cool graphics to our game most particularly we're going to be adding a player model so that's going to be really awesome before we get started I just want to talk about what's going on with this so if you haven't seen my latest 2d platformer video you don't know that I've changed this video format so I hope you like it as it is now and also I've made a survey where people could answer some questions about how they would like the practice video format to be in the future future and I'm going to make a forum post about that which will be in the description and we can see some of the results on what people have voted for but definitely most people voted that I should keep the face cam so that's what you're going to be seeing in this video so I hope you can bear with me if it's not something of your liking but the people have spoken sort of see so I'll really try and have it so that the face cam is not too distracting or doesn't cover anything up so with that said let's go into today's video all right so you can see um I have this player model folder and I haven't really decided where I want to upload this yet but a link to download it will definitely be in the description and this is an awesome robot model made by semina iDEN and a link to him is also in the description he does client work and he's just great to work with I've done so multiple times and he has great prices and is really experienced so definitely check him out but anyway so we can just import this entire folder you can see it has an FBX file that's a model file and that can be basically opened in pretty much any 3d modeling application if you want to change something we then have the textures for the parts of the robot and for the body which is just a sphere here so you can see we have the different textures in there and the model file itself so what we want to do is simply take this player model folder and drag into a unity just like that and unity will start import all of the different assets this might take a little wild depending on your computer speed I'm recording here so okay it actually wasn't too bad and then it's going to give you a warning here that says it can calculate tangents this can just be ignored that's because we have an empty object within the model hierarchy which we're simply going to delete so it doesn't matter that that's giving us a warning there so you can see we have the player model here and I just want to start by dragging this into the scene and you can see it there and of course make sure the transform is reset and you can see it's way too large so let's go into the play model import settings and scale this down to 0.1 and then hit apply and also now that it has imported the materials we can go ahead and uncheck that and then we can see we have some tangents here we want to calculate those and import the normals so that's perfect hit apply on that we can go into the rig make sure it's set to none and animations and just disable that because there are no animations with this model we're going to create them on our own so you can see now we have the body and parts those are just textures and then we have the materials folder and it's automatically created two different materials for us and that's not quite how we want it set up because if we just move this guy up a bit and our shadow quality is currently awful you can change that under the project settings quality I'm just going to keep it because I'm recording whilst doing this so we can bump it up later so again we can select these different materials and if we just take the body one and color this black you can see that it isn't applied because we lost that connection when we told you not to import the materials so we can go ahead and apply this to the sphere there and then the insides here let's just rename this two parts I'm just using these materials you can go ahead and create them on its it's basically the same thing let's just make this red and we're going to add that to this and to the thrusters those are the pipes and then we can create a three one material and this is going to be the highlight and we can just make this blue and drag it on to there good just so we can know what is what here and then we can expand the player model hierarchy and delete the first object here that one is empty but the rest we are going to need so this is going to be our armor or parts or whatever your armor this is going to be our thrusters this is going to be our body and our eye light so all of these naming and how you choose to do materials it's completely up to you you can take this model and do whatever you want with it but sameen has provided some really awesome materials so let's set those up so let's stop by the with the body here change that to a complete white because we're going to be using a texture to define the old video channel and that's the build body color version here so simply click that and that looks alright but the magic happens when we go in ahead and choose a texture for the metallic setting also because you can drag this around and all that but if we have it defined by a texture things start looking really awesome so simply select the body metal here and you can see what kind of cool shiny look that gives us then we select a normal map that's the body normal and you can see that it's not marked as a normal map we can simply click fix now or you can go ahead and find it and choose normal and then we want a height map and that's going to be our body height and yeah that settings going to be just fine so you can see that is a very nice shiny material that we have there of this kind of well used robot I mean it's not exactly factory new so it's it's well worn good and then we can have some textures for the parts here so again let's change this to white going to the albedo and select parts color then undo metallic and select parts metal and under the normal map and select parts normal and again fixed now and you can see that that gives us this awesome looking texture it's a hand-painted cool so I'm actually really satisfied with that however I want to change the slide just a bit instead of changing the albedo I want that to be some kind of gray and then do an omission instead and we're just going to make this a light blue something like that and you can play around with these settings to make it look even better but I think that gives a really nice impression that this is kind of glowing from the robot we're also going to add some thruster particles at some point but I don't know if we'll be doing that in this tutorial we have a lot of stuff to cover so now that we have this set up and you can say just throw sin that morning again we can just clear that now that we have this set up we can go ahead and add this to our player object so let's drag our player into the scene let's drag our you can see under graphics here we have a player model let's just drag our new player model under there delete the old one continue we are going to lose our prefab connection and then reset the transform on this one and then we can simply hit apply again here to bring back the prefab connection here and you can see that the thrusters are made in such a way that we can actually tilt them in order to simulate the player moving because of force applied from the thrusters so that's kind of the animation that we're going to have some when he's idle we are going to have the thrusters pointing downwards when he's moving forward we're going to have them pointing backwards and when he's moving backwards we're going to have them pointing forwards so that's going to look really awesome but you will also see that he's currently rotated by 180 degrees so we're going to flip him over so let's just take the entire player model here and we could just scale him on a negative one on the Z here or we could Tatom I mean this is simply a matter of preference I'm just going to do a 180 on the Y and that's going to work just fine I don't think it's going to have any influence on well anything great so that already looks really awesome and we apply these changes and delete the player we can already take him for spin and these changes will be applied to the actual game or to the network so he will spawn with a cool player model you can see some issues appear however you can see that when we spawn we are actually able to see our own player model and that might be fine for some things but if we have this huge huge piece of armor blocking our screen that's not really something that we want to see so we are definitely going to have to set up some kind of system for disabling that I mean if we go under our player here drag it in here and go under the components to disable but there's nothing nothing really telling this that the Koenen components that we want to disable should be on this object it could be components on other objects and therefore we might just go around and disable renderers on other objects so we can simply add some to this and that's maybe something that we want to do for now so let's just change that so we have room for one more and then find let's lock this and then add a tab inspector add another inspector have this over here that one is locked this one is not then we find our armor and take the mesh renderer on that and drag it know that can actually not be disabled here so it seems that the mesh renderer is not actually a behavior okay it's definitely a component but it's not a behavior so that's fine and that that's definite is something that we can take care of I mean we can add another list here we can add a custom mesh renderer we could have a list that disabled objects or we could add a mask to the camera we have so many options for getting this to work however what I want to do now is simply ignore it so let's just see when we'll have time for that it's an easy fix when we get to it but right now I have some other stuff that I want to focus on so let's just close that tab there and we'll come back to it a bit later so what I wanted to have a look at now is synchronizing is is animating these thrusters and then syncing that over the network and unity has some awesome ways I'm syncing animations and they have what is called a network if we go and here a network animator which requires a normal animator as in a variable slot and then you are able to choose what properties you want to sing over the network however that doesn't smooth anything out so if you want smooth rotation which is something that we want smooth blending that doesn't really work so what we're going to do is we're going to rotate these locally and then add a network transform child to sync their rotation over the network because that will actually apply smoothing so it's maybe not the best way but it's definitely going to work just fine so let's do that let's start by adding some animation so let's find our animation window it's under window animation or press control 6 and in here if we select our player we're able to create a new animator and animation clip let's set create go onto our player model make a new folder called animation go under that folder and in here we are going to let's make the idle animation first and we can simply make sure that this is red and those are red and then we can go on to graphics player model thrusters simply select those again make sure to click this and now we are recording so that means that we can actually change our rotation here so these are actually a bit offset I don't know if you want to start with those offsets let's just disable the animation there and try and reset this no because we want them to be scaled let's just zero that out zero that and that out no it doesn't look good okay so we'll just keep all of these settings and then only change this that's fine so let's hit record again and when we're not moving well we want to change those so they are pointing downwards and the anchor here is not perfect so let's just do about negative 40 that should make them point downwards yeah just by measurement of the eye and just to make sure that this is working let's copy these keyframes move over with one second and paste them again so we're just going to have this animation state here it's not going to do any animation on the timeline we instead going to be blending using the speed of our object but you'll see that in a sec so let's now create a new clip let's call this one move forward and again select the thrusters make sure we're recording find the rotation parameter and I believe we're simply going to set this to negative 90 that looks right and let's copy those over to one second great let's create the last clip here and this is going to be move backward and again select the thruster record and let's simply select zero here copy that for one second stop recording and that was it that was all we needed to do to make our animations and we can just close those off now let's go into the project go and do the pom pom pom pom pom player model animation and find our animation controller here called player just going to call this player controller or play your animation player and them controller there we go let's stop a click that to open it up in the animator and let's just make some room for the animator here and you can see that we have three animation states we have an idle and move forward and a move backward and they each have their associated animation so idle move forward and move backward but we should just go ahead and delete these because we don't want to transition between them by using some kind of boolean state or whether or not we are passing some kind of requirement and then we transition no we want to transition fluently so we want making them the unity animation system to blend between them and therefore we can create what is called a plain tree so right click create state from new plan tree and we can go ahead and rename this to move because it's basically all of our movement in one state and if we then double click on this we open up the move blend tree and you can see this have has a blend parameter and currently that goes between 0 & & 1 and that is kind of that that is the value that will blend between the animations so that's going to be represent our forward speed so we can go ahead and rename this to forward and I was going to say speed here but senses can both be a negative and positive for forward and backwards movement I'm going to say forward velocity and but currently this goes from 0 to 1 and I'm going to show you how to change that so over here in the right hand side we want to add our three motions or 3 animation Clips so let's create add motion field add motion field add motion field in the middle we're going to put our idle at the beginning we are going to put our forward and down here we're going to put our backward then we uncheck automate thresholds and then we say okay when we're moving forward we want to this to be a one when we are standing still we want our speed to be zero and when we are moving backwards we want our speed to be negative one so we have this value clamp between negative one and one and the animation will be will blend using this value so if we now select our player and select our blend tree we can actually preview this down here it's currently set to zero if I okay so this is a place where my FaceCam is probably blocking everything let me just move this up a bit here I promised I wouldn't let it block anything so here you can see it just add a a forward velocity of zero if we then move this up you can see that the thruster is go backwards and if we move it down we can see that they turn forward here so that's perfect so we can easily blend between this in a very nice and fluent way so I'm going to move this back down because we're not going to be needing it anymore there we go and we can basically start applying the forward velocity using a script so we can just drag this back here there we go then we can select our player make sure that we have our player and controller here and that everything is looking great which it is then we can go in and find a script where we can change this so I suggest we do that inside of the player controller because this is what where we calculate our velocity where our speed variable is which we are going to be needing in order to make sure let's clamp between minus 1 and 1 and all that stuff so in here let's add a new serialized field private animator which we are just going to call animator and then in this start method here actually let's not make this a serialize field let's require this so let's we require component of type animator let's move this down here where we cash out components so this is component caching and then here we simply add it so animator equals get component and mater there we go now we're sure it's there because again animator nut animation because we required a up there so for some reason the recording cut out here and it's lacking some audio but I'll just quickly tell you what we did first off we removed the dot normalised but we kept the parentheses you see me adding them back in there then we change the two input lines from get access raw to simply get access that makes the input much more smooth we could smooth that ourselves but unity does it it does a great job actually next up you can see me making a comment here because we are now animating our movement we do this by calling set float on our animator the float we want to change is forward velocity and we want to set it to this set movement and just clear out some warnings here those are just from the new update and they're definitely not important so we won't be looking at those right now and this should now be working locally so let's try and remove that after having applied the changes play the game going to land host and we can maybe zoom out here so we can see what's going on land host yeah it's working so you can see how this is smooth the movement is now much smoother and I think it's a nice amount of smooth it's not overdone and you can see how the thruster is down here change as we move cool so that actually looks very nice and I think it helps give the impression that this robot is actually moving for reason not just adding forces out of thin air next up is sinking this over the network and that might sound really difficult and I definitely had some trouble figuring out the best way to do this but once you know how it's really easy so let's just search for chat transform and then add the network transform child component we've already added one of those up here and we're going to add one with basically the same settings except this time if we drag the player into the hierarchy we're going to go into the graphics player model and instead of having the are having the camera transform we're going to have our thrusters as the target and the movement threshold is going to be the same here again in turbulent movement it's going to be zero this is final point three and we only want to sink our X so it's all of the same values as up here but remember to change the target then we're going to apply this and we can again remove this from the scene and I think we are ready to build this actually so whoops some kind of null reference that's caused by unity I think I don't think we need to worry about that so let's just make sure yeah we have a target here and our animated looks fine I can't see any issues with this so let's try and build this control V or command B and see if it's working so this is taking an odd amount of time here okay great and hit plane here actually I'm just going to wait for it to calculate the lighting here there we go and you can see here that this is waiting so let's make this the host and make this decline and watch this guy now as we start to move no okay so this is not working and I know why do you know why think about this okay so if we take a look at our player here actually I should have waited and taking a look at the other guy so in here we have an animator we have a player mode and a player controller the animator uses the animation controller to every frame check for different values and then transition the animation depending on those values and those values are the properties or the parameters up here and this starts it's a value of 0 so we have a starting forward velocity of 0 unless it's changed by the player motor or the player controller however under our player setup we have this array of components to disable we disable the player motor and all of a bunch of stuff we also disabled the player controller so that's me that means that for all clients which are not the local client the arm or for all players which is not the local player the player controller is going to be disabled and therefore the animator is never going to experience a property of forward velocity other than zero so it's always going to have a forward velocity of zero there's nothing there to change it and that will overwrite whatever information we sync using our network transform child so if we stop this now and find our player we can actually simply expand our player setup go into components to disable add room from one more and drag in our animator and I think that will do it so I think that will basically be it so now we can build this one more time oops hit the wrong key there let's build this one more time and hopefully this time it's going to work let's have that there and this is why net debugging over the network is so difficult because you can have stuff overriding each other without giving any errors and it's K can be such a pain to debug so again let's observe here let's drag this over here client again look over here yes so now it's working that was indeed the error and it actually looks very very smooth with these physics here we have going on it really looks like he's floating on some thrusters so I think that's just perfect and you will notice that if we give it a bit too much force here and drop down you can see the thruster simply clip through the ground but I don't think that's an issue right now I think we have other stuff to look at so that looks really really cool what the heck let let's add some particles so now if we drag our player in here we can we can add some player thruster particles down here so in order to do this let's right-click go import package particle systems because if I remember correctly unity has some really cool default thruster particles we're not going to be spending too much time on this that would be kind of silly but I definitely think that we should add some of them did I not hit particles here we have all kinds of control stuff don't want any of that none okay so that's like none here and just find the ones that we want so the standard assets no input all of the particle systems of the prefabs don't think we're going to be needing any of the scripts let's just keep them shaders textures none of the utility none of this other stuff okay so that's all we're going to be using here so let's import that this might take a little while okay that was actually quite speedy again let's go into the console just clear those warnings and now we can go into standard assets particle systems now you can see we have some different stuff in here let's find a cool prefab so let's find the afterburner one this was exactly the one that I wanted to find so you can see this is a quite a huge particle system but I think it looks really really cool and it gives this subtle but awesome looking effect of an afterburner so let's definitely keep this but just change it a bit so we definitely want this to be smaller in any kind of way possible so we have this glow here it's that just that's another particle system and the afterburn itself so the glow okay it's just a centered glowy effect there let's just take this one at a time so let's start by looking at the afterburner and this is currently really long so let's start by changing the last lifetime on this to something like 0.1 and maybe bump down the start speed a bit too so let's set this to 20 think that looks a lot better and definitely we want the size of these to be much smaller too so let's try 0.2 and to 0.4 that is better but we definitely want the speed to be lower 10 looks pretty decent but we might want to spawn more or set this lifetime a bit longer because currently we can see between these so the rate here is 80 and that's already a pretty high spawn rate but we can set it to 120 that's not going to matter and this is starting to look like something that we can add to the first edge here so let's just take this now going to player graphics player model thrusters and let's add the afterburners here so let's go on to thruster let's reset the transform on this let's drag this out down here try and position these as accurately as possible yeah that's not far off so let's drag it down a bit something like that and we also need to rotate this to point the right way almost correct oops something like that looks like a great starting point awesome it's not totally even we can do better that looks pretty great awesome so you can see here it's still a pretty long effect so I think we can actually just make the speed lower again so let's change this to 5 yeah that looks much better and we can even move it a bit up in the tube that's fine and then we need to rotate it a bit in widths actually we can do a bit more something like that that's might maybe a - a bit too much yeah that looks really great and move it over a bit awesome and you can fill it around with this as much as you want I'm just going to keep it like this for now and then we can add the globe back in and this is going to be probably a too big a bit too big now you can see just how large that is it goes all the way through the ground so let's just change the speed of this on to four and it's going to limit it whoops I don't know why it zoomed out so far there we go see just how launched these particles are so the stat size here is going to be something like 0.5 to 0.6 looks better and the lifetime 0.3 smaller point one point two two point four three two that's pretty I actually really like the look of that for some reason it goes out really far when I try to focus on it so let's try and simulate that that looks awesome okay so I'm really happy with that effect I think we can just go ahead and add this to the other side as well so this this is going to be afterburner one we can duplicate this and do afterburner two actually let's make this left and right so this is going to be afterburner underscore it left and this is going to be afterburner underscore right and we're going to look from the direction of the player here so we are going to inverse the x-axis like that and then we are going to be can maybe just scale it on the X as well that's doing negative here no that doesn't work so we have to inverse on the rotation here as well so let's the up-and-down that's going to be fine so the Y here should be shifted a bit and I think that looks pretty great yeah so let's go ahead and see how that looks in the game so close that close that then and that let's hit apply remove the player save and let's hit play LAN host whoops okay so we are definitely flying something is happening here maybe I forgot to remove some script or some swords on these so the thrusters are here you have to burn it yeah there we go they have a physics force and a Collider we want none of that so let's delete them both the physics force and the collider they were adding some kind of force we don't want that to happen so that's it applied to that again say that going and hit play land host it says the reference script on this game behavior is missing so again there is something so let's just move out here find our player graphics play model thrusters it's like both glow objects and let's remove that not that it matters but it's nice to just remove a unnecessary warning that also always feels good so let's apply that delete the player let's try this one last time so let's say play LAN host and now you can see the thrusters are looking great so we can of course get those to vary depending on what we are doing for now I just want them to be a constant thing give the impression that something is holding us up we can definitely also do some hover bouncing or something but we'll see with all of that so that was basically all I could come up with for this tutorial next time will probably take care of the stuff that is currently blocking our screen maybe do something about the environment - I don't know so we'll have a see in the next video but thanks for watching I hope you enjoyed it and I'll see you in the next video
Info
Channel: Brackeys
Views: 96,419
Rating: undefined out of 5
Keywords: unity, unity3d, tutorial, asset, assets, model, texture, models, textures, material, materials, settings, how, to, howto, learn, course, series, tips, tricks, tutorials, workflow, tip, game, development, C#, multiplayer, fps, first, person, shooter, graphics, gfx, player, animation, fbx, import, unet
Id: T_03RZTdIkk
Channel Id: undefined
Length: 36min 53sec (2213 seconds)
Published: Sun Jan 03 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.