Adding The AK-47 Weapon - #8 Creating A First Person Shooter (FPS) With Unreal Engine 4

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] don't afternoon ladies and gentlemen boys versus here and welcome back to my Unreal Engine 4 FPS series in today's video we are going to be showing you how you can finally add a weapon into your game because as of right now we are just a set of character a character and a pair of hands walking around well quite literally empty handed so what are we doing is showing you how to get a weapon in there it's going to be an ak-47 one thing that you guys do need to do before you do start off this video is go ahead and download the project files from my website inspector Tubbs calm and then inside of the first person shooter resources you should have these files one for the ak-47 model itself or then you've got the diffuse the normal and this specular as well we're going to be importing all of that in today's video and getting that weapon in the players arms now one other thing that I wanted to do before we do go any further is actually just fix up our blends place a little bit so what I mean by that is when I start walking forwards and then release that button you can see it really quickly flicks back to our idle it doesn't look smooth and it just doesn't look great so all I'm going to do it has a little bit of fade between the two animations and that's all done inside of my walk around blend space so if I go ahead and set my interpolation time to one that's pretty much going to fade between the walk run and the idle it just makes things so much smoother so once you've done that go ahead and close it press play and now when you walk forwards and let go you can see it's got this nice fade as opposed to like a dirty flicker so moving on let's go ahead and import this weapon into our game so what I'm going to do for now is go into my blueprints folder and I'm going to go straight out to the main bit here and then I'm going to create another folder for weapons so I'm going to open that up and inside of there inside of my weapons folder I'm going to create another one and I'm just going to call this ak-47 once we've done that open it up and then from there if we go ahead and grab our obj file now to drag this into your scene just like that and then we need to make sure this is imported as a skeletal mesh since we're going to be doing some stuff to it later on and then don't worry about setting the skeletal mesh just leave that completely blank by leaving it blank is going to create one using this mesh for us which is exactly what I wanted to do and then just go ahead and press import give it a couple of seconds it will load up and then once it has loaded up what we're going to be doing is don't worry about this all we're going to be doing is simply grabbing these textures now and just dropping that into our scene as well so give it a couple of seconds to import those it's just a free text its diffuse normal and specular using these materials or these textures different allow us to give a little bit of extra life to our weapons going to the color depths and all of that good stuff now by default it would have created this ak-47 material it just doesn't look that great so we're actually going to be deleting that so what I'm going to do is quickly delete this and then we're going to make another material for our weapon and I'm going to show you how to quickly set up your normal your diffuse and your specular so right click in your content browser and create a new material and then with this material is called ak-47 underscore Metz open it up and then once you're in here go ahead and press T to create a texture sample or right-click and just type it in it's entirely up to you and then with this first one I am going to be using the diffuse and then just go ahead and hook the top little mode up here to the base color and this is going to give us a base color for our ak-47 so now you can see we've got our word we've got our mettle and that's all good and then if you select the normal map and then press T so basically if you select an asset in your content browser then press T it's going to automatically bring in that specific texture which is great so do the same thing for your normal you can see we've got that there and then do the same thing for your specular as well and now all we've got to do is just hook these up to the right little modes in my normal goes into my normal and then my specular goes into my specular and it's as simple as that now you guys could fiddle around with the roughness and the metallic values if you want to make it look a little bit prettier it's entirely up to you but for now this was the purposes of this tutorial I think this is going to be just fine so go ahead and play those changes and then what we're going to do now is go over to my a k47 skeletal mesh open it up and make sure the weapon has come in now as of right now with this model is standing up right it's not too much of an issue as we're going to be playing around with the socket creating a pose for this but what I do want to do is just quickly check over the weapon you might want to turn your camera speed down as it's just so you can be a bit more careful just make sure there's no clipping no intersecting polygons or anything like that but once again I have checked this model so you guys should have no issues with it at all so one thing that we do need to do with this is we actually need to quickly set a material for it now setting material is all done the left hand side on the asset details just go to material slots and then all we're going to do is set this to ak-47 underscore max give it a couple of seconds to compile the shaders and you will get that on your weapon so just make sure this is all updated over here so if we open this up it's compiling shaders at the bottom there and that's why you can't see and that's why it's still that color give it a couple more seconds and it won't come to life as soon as we've seen the material is working on the weapon all good we will move on to how we can actually turn this into a weapon that's going to be spawned in again so it's got ten shaders left should take a couple more seconds and we're all good so what I'm going to do for now is I'm going to move back into my second screen or you can disclose it it's entirely up to you actually there we go it's all loaded up so now you can see that we've got our weapon here we've got the wooden back bit the handle and the front leg so good so what we're going to do now is we're going to focus on getting this into the game so we've got the physical side of the weapon all set up that's fine so let's get it into the game so what we're going to do is create a new blueprint class and this blueprint class it's going to contain all of the information for that weapon so this is going to be where we're adding all the code in for firing the weapon animating the weapon and all of that good stuff so just right-click on your content browser and an active class and then just call this weapon underscore base for now sorry so right-click rename and set this to weapon underscore base now the reason why I'm not actually going to be creating this as something like ak-47 and the school weapon is because I'm going to be setting up in what sort of a template verse so basically if I want to add in another weapon later on say something like and m4a1 all aboard do is just copy this weapon base and now to change the model and it's as simple as that so for now let's just go ahead and open this up and what we're going to do is we're just going to put the ak-47 skeletal mesh in there for now so just drop the skeletal mesh in there and then for the mesh on the right hand side you set this to a cave and that is going to bring in our weapon so compile that and let's just go ahead and close this up now so next thing that we need to do now then is actually give the engine a way to know where we want to place it in our game so the way we're going to be doing this is actually with our character we've got to create a socket for that weapon to be attached to so open up your SWAT character skeleton so for me that is over here in my skeletal mesh and then if I go ahead and go ahead and hop over to my skeleton inside of here we need to socket it to a part of the body now for us the most easiest place and probably the best place to socket it to is going to be the right hand it's where they're always going to be holding that weapon so on your left hand side in your skeletal tree just navigate down to your right hand right click and then from there just add a socket once you've done this just call it weapon underscore base or weapon underscore attach even and then with this what we're going to do is we're going to right click it now and add a preview mesh and this preview mesh is pretty much going to allow us to and define how the weapons going to look sort of the placement the scale and all of that good stuff so what I'm going to do is set it to the aka mesh here now the only issue was pissed at the moment is you can see this is absolutely massive it's way too big so we need to play around with the scale and all of that good stuff so what I'm actually going to do is I need to set a preview animation so I can see how this is actually going to be held in the game so up at the top where you've got your details to switch to preview scene settings and then from here for the animation we're just going to set this to the idle just a preview of for now so go ahead and check in your idle animation but I don't understand even and then with this you can see our gun is all over the place it's way too big and it's off for the rotation and everything so what I'm going to do is simply first and first I'm going to rotate it so it's facing the right way just use these transformation tools at the top here so just rotate it on to the side and then just flip it up and make it face forwards with the weapon so aim it down a little bit now it can take a little bit of time to do this section once you have done it is really really simple to just move it around obviously if you have this right scale it's going to be a lot easier as well so just scale this down a bit and then with this just go ahead and drag it into our hands just like this now you don't necessarily have to get it a hundred percent perfect right now you can always play around with that later on in the video but what I am going to try and do however is simply line up my hands and also my little trigger for the gun as well so you can see the character's got his trigger finger here to try and slot that through there and then for the hands try and get that in there as well so see if I can get down aim it down a little bit for me I think that's going to be just about okay there now we can play around with the scale and stuff later on it's something you guys can do in your free time but for me that looks like my character is holding the weapon and that's exactly what I want so now that I've done this we need to focus on actually getting this weapon spawned into the game now so go ahead and close this and then with our character so for me that's going to be our third person character open that up and then inside of here we need to do a little bit of script to actually spawn that into our game so go into your event graph ignore the take damage stuff if you've got that open already and what we've got to look for is our begin play now as of right now we've got some heads-up display stuff in there just completely ignore that and just go after this now pretty much all the time our heads-up display is going to be added in there so we can just do it after that hooks up to begin play anyway and then from this what we're going to be doing is spawn actor from class and then with this spawn actor what we're going to be doing is pretty much spawning in that blueprint actor that we created earlier for our weapon so with the class obviously we're going to be setting this down a k47 so or weapon underscore base so weapon underscore base just go ahead and select this and then with this what we're going to be doing is grabbing our spawn transform and just type in make transform and what this is going to do is just give us some 0 values for location rotation and scale we don't need to change it from here because what we're going to be doing is we're actually going to be attaching all of this stuff to a component as opposed to the normal make transform so drag out your return value and then just type in attach to component and then the component that we're after is going to be our mesh so get a reference to our mesh and then for our socket all we're going to do is set this to weapon and then that should be underscore attached make sure you've got the socket name a hundred percent perfect otherwise it will not work so if we go ahead and open up our character and our skeleton just go ahead and double check that to open up your SWAT character go into the skeleton just from the little thing up here and then just check that our socket is called weapon underscore attach that is all good for me so I'm going to close this now and I'm going to close my SWAT character and go back to my third person character and you can see as of right now there's no weapon in that because we haven't begun playing the game however if we go ahead and press play now you can see we've got our weapon in our hand we can walk around of our ak-47 and it looks really really good now bear in mind you have got a little bit of clipping where our camera goes through the wetland a bit that's a really easy fix and you can see our hand placement is also a little bit off as well but once again that's just entirely down to the way that we've got our socket set up you can play around with that it's really really simple so once again all you got to do is to just go into our skeleton open up our SWAT character head over to skeleton and then if we set the idle animation as the preview all you've got to do is just adjust this if you wanted to you can even do that in real time so if I press play real quick and now with this window open as well if I wanted to I could go ahead and select the socket so let me show you how you can do that so if I scroll down and then grab my weapon attached if I now move this around so move it left or right it's going to move the weapon in the game as well which is quite nice so I'm going to move this down a little bit just pop it in the hand there press close and there we go and you can see our weapon is being held a little bit better now bear in mind this weapon is not made for this rig so the placement is going to be off slightly a little bit but it's not too much to worry about but for now we have got our weapon in the game now just a quick fix for the clipping that you're going to have with your weapon that you saw earlier all you've got to do is go into your project settings so go to project settings and then give it a couple of seconds for load up and then all we got to do is change something called the near clipping plane so basically when an object is near to the camera it's going to clip through it and it's going to get rid of some of the polygons we don't want that so all we're going to do is go into our general settings which is somewhere so if we just scroll down to engine general settings scroll down and it's near clip plane the one over here set this to one instead and then if we go ahead and close that and restart the engine it's going to get rid of all of our clipping but for now you can see we've got our weapon in the game we can walk around with it but we can't shoot as the shooting that's going to be something that we take care of in a later video anyway guys that is pretty much everything for getting our weapon in-game once again thanks for watching stay awesome keep rating your boys versus signing out this series was made possible by you guys supporting me on patreon if you want to help create other series like this and check out my patreon page and the link in the description [Music]
Info
Channel: DevSquad
Views: 238,712
Rating: undefined out of 5
Keywords: Unreal Engine 4, UE4, FPS, FPS Tutorial, FPS Game, First Person, First Person Shooter, Unreal Engine 4 FPS Tutorial, unreal engine, VirtusEdu, Virtus Learning Hub, Game Dev, Game Design, Shooter Tutorial, How to make a FPS game, Beginner, Blueprints, Unreal Engine Tutorial, FPS Tutorial Series, Camera, Tutorial Series, Player, Armor, Damage, Character Animation, Custom Character, Blendsplace, Animation Blueprint, Weapon, Gun, Ak47, AK-47, Adding A Weapon, Weapon UE4
Id: YCdAX6zhyBs
Channel Id: undefined
Length: 15min 10sec (910 seconds)
Published: Thu Jul 20 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.