How To Set Up The Ultimate... Ultimate True First Person Camera - Unreal Engine 5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys mizo frizzo here and in this tutorial I'm going to be showing you how to set up the ultimate true firstperson camera this is an updated version of my old video I've made some improvements but uh for anyone who hasn't seen my old video this is a true firstperson camera so if I press f8 to eject here you'll see that my character is looking down and if I look up and press f8 to eject you'll see that my character is looking up and and one massive Improvement that I've made with this new version is that I have eliminated all camera wobble that is inherited from the Running Animation so as you can see here it kind of uncannily just Glides along even though this animation is taken straight from the third person template and has quite a lot of motion in the headbone there we are eliminating all of the camera wobble inherited by the animation even in jumping you can see this is nice and smooth which means that if you want to add some camera Shake later on you can do that but none is inherited from the animation and as a bonus here guys I'm going to show you how to set this up for replication as well so if I just change the number of players here to two and change this to new editor window so we've got two windows here you'll see that I've got my two players here and this looking up and down this kind of vertical aim offset procedural vertical aim offset is replicated and I can press shift F1 to get my cursor back and switch to the other window and you can see it's also replicated on this other player so without further Ado guys let me show you how to do this all righty guys the first thing I'm going to do is create a new project using the third person template leave everything as default and hit create once the editor has fired up I'm going to go ahead and find the third person folder and blueprints and open up my BP third person character what we can do is first drag the camera boom onto the mesh and parent it to the mesh and we're going to change the target arm length on the camera boom to zero and now we are going to choose a parent socket here but instead of just parenting this to the Head what we're going to do is create a virtual bone so that the camera doesn't inherit any of that wobble from the head so what we need to do is find the skeleton of this character and that is in characters and mannequin and meshes and then you'll see SK mannequin right here open up SK mannequin and I'm going to find the head which should be down here the head I'm going to right click and add a virtual bone and the target bone I going to choose is the root and I am just going to leave that as VB headcore root but I'm going to click that and contrl C to copy the name and then I'm going to head back over here to my BP third person character go to the parent socket of the camera boom here and search for my VB head rout and select it it and then I'm going to zero out the location and the rotation you'll see this will drop the camera down to the position of the root here I am just going to move this up to about the position of the eyes um I don't want this inside the head I want it just ever so slightly in front of the head so I might just change grid snapping here to five and move this one more click forward actually let's make the location here uh 12.5 there we go and that height is good for me I'll leave it at 170 uh you can place this wherever you like but just in front of the face there at about I level is probably good for a true firstperson camera okay let's uh set up the rotation of the spine bones but uh actually just before we do that let's change a couple more things in here so you can select the root in the components tab here and then search for your and you want to check use controller rotation your and you also want to search for Orient and uncheck Orient rotation to movement so if we hit compile now and play you'll see that uh we can look around and our character rotates with the camera but our character doesn't Bend up and down to look around so that's what we're going to set up next where we're going to do that is the animation blueprint so over here you can find what enim class is selected obviously this is Quinn and it's selected ABP Quinn um if you wanted to change this to Manny and change the ABP to ABP Manny you could do that but either way uh if I just hit browse here to browse to where the uh animation blueprint is either way all the changes that you want to make you want to make them inside ABP Manny because ABP Quinn is a child of ABP Manny so we're going to make all our changes inside of ABP Manny so open it up and the first thing I'm going to do is grab the character reference here and drag it out and off of that I'm going to get the control rotation get control rotation and what I can do is right click here and split the struct pin and this y pitch is what we're going to be using to rotate the spine bones of our character so the first thing I'm going to do is drag off here and I'm going to find a subtract node and then I'm going to hold control click and drag this onto the second pin here because we are going to subtract it off of 360 so 360 minus the Y the next thing we're going to do is also negate it so we're going to multiply it by -1 and we are also going to check if it's greater than 180° and we're going to use this to select float select float plug this one into a and this one into B and then we are going to divide this by the number of bones that we're going to apply it to so I'm going to divide it by five because we're going to apply it to five spine bones and then I going to make a rotator and I'm going to leave that plugged into X roll because this is actually the one we need to apply it to I can drag off of here and promotes a variable and we can call this pitch Rotator or something like that and add an execution pin here plug this in and then just to make this a bit neater what I might do is select all of these and right click and go collapse nodes and I'll just call this calculate pitch or something like that okay so that's our pitch calculated we now need to apply it to our spine bones so we can go over to the enm graph here and I'm going to grab this stuff here and move it way out to the left and then I'm just going to right click here and I'm going to search mod and find transform modify bone can plug this in here and I'm going to select this node and I'm going to unexp a few of these pins because we don't need them so over here in Translation we can click the pen here and uncheck expose as pin we're going to keep rotation it's the only one we do need so we're going to keep that one but we're going to change rotation mode to add to existing and then scale unexposed that as a pin Alpha unexposed that as a pin so you've just got this one pin rotation and the rotation mode is set to add to existing once we've done that we can select it and contrl D to duplicate this four times so that we've got five of them we can plug these all in like so and then we can also select the bones that these are going to modify so we'll select the first one and we'll change the bone to modify to spine one select the second one change the bone to modify spine two spine three spine four and spine five and then we're going to grab our pitch Rotator drag it out here and plug it into the rotation on all of these here like so nice if we compile now and we hit play we should be able to look up and down and we can very nice and we're not inheriting any of that movement from the animations it's nice and smooth very good nice that's all set up and ready to go one thing you will notice if we now change our multiplayer options to simulate multiplayer say we change this to number of players two and net mode to players listen server and new editor window here for the pi you will notice that ah we don't have two player starts here I'm just going to uh duplicate this player start so that they are facing each other so I'm going to hold alt and shift and click and drag this out and then I'm going to rotate it 180° just so our players are facing each other and now if I hit play you'll see that this is uh this is replicating on the server because obviously the server knows uh but if I go and select the other player and do it you'll see that the client doesn't know when the server is looking up and down so this sort of looking up and down is not replicated properly um I'll show you very quickly how to set that up so what we need to do in our vent graph and on the camera input here I'm just going to grab this and move it down here make a bit more space I'm going to create a new variable I'm going to call it pitch whoops pitch of type float and with pitch selected over here I'm going to change replication to replicated like so now we can't just set this here and this automatically be replicated that's not going to work what we need to do is we need to set this in a multicasted um RPC um remote procedure call so what we need to do is right click here and create a custom event and I'm going to call it MC for multicast set pitch and I'm just going to contrl C this set pitch so I don't have to type it again because I'm also going to create a custom event and I'm going to call it R for run on server set pitch like so this one over here replicates is going to be run on server and reliable and multicast here is going to be multicast and reliable and what I'm going to do is I'm going to set pitch on this multicast IPC then I'm going to grab the pitch and plug it into this node so that when we call it here so we're going to On the Run on server pitch we're going to uh call multicast set pitch and then we've got this pin here that's been created so when we call that custom event it's got this pin here and I can then drag it onto this one and then off of the end here when our character looks around we are going to call the run on server set pitch and our pitch is going to be our control rotation so we can get control rotation right click here and split the struct pin and plug the Y into the pitch right here very good now that's all set up but we also need to um we need to be able to access this pitch inside of our third person characters animation blueprint so we're going to go back to our animation blueprint here in the event graph and what you'll notice is if you grab the character reference here and you just get pitch it will not come up because this reference here is not a direct reference to our third person character so we're going to delete this cast and we're actually going to cast to third person character plug the these in plug these in here and also select this character uh set variable here and change the variable type to third person character object reference and object reference to our third person character change variable type and now if I go back here and drag off of this you'll see I now have access to the pitch so what we can do is we can just go into our calculate pitch node here and off of the character reference here we can get pitch then we can hold control and drag these onto pitch right here we can delete get control rotation and now we have a this is based on a replicated variable so it will now be able to replicate across all clients um the reason for this is is that the way that Unreal Engine replicates movement in a very efficient very sort of optimized way that um you know minimizes the use of bandwidth from the server um it doesn't include the uh sort of control rotation the camera rotation of the characters it's just not a thing that's replicated by default so now if I hit play just make these a bit bigger you'll see see that this one is replicated over here very nice and if I press shift F1 to get my cursor back and switch to the other character this one is also replicated very nice all right guys if this tutorial has been of any use or value to you whatsoever please hit like And subscribe and I will see you on the next one
Info
Channel: MizzoFrizzo
Views: 9,793
Rating: undefined out of 5
Keywords: video games, video game development, true FPS, how to create a true first person camera in unreal engine 5, true first person camera, TFPS, unreal engine tutorial, unreal engine 5 tutorial, ue5 true first person camera, ue4, ue5, first person shooter, how to make a game, third person shooter
Id: fnk4snQyWVY
Channel Id: undefined
Length: 15min 52sec (952 seconds)
Published: Thu Feb 22 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.