How to Make the Gap In the Wall Puzzle in Unreal Engine 5 | Resident Evil 7 Puzzle

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back game developers today we're going to be recreating the Resident Evil mechanic of squeezing through walls to get from one place to another I know this is in Resident Evil 7 for sure with the first- person perspective but it may also be in some of the other games but before we get into it I actually looked for other tutorials for the same mechanic and didn't find any so it mean a lot if you guys could like subscribe and comment down below for more tutorials or videos in general you guys would like to see in the future also we are really close to 1,000 Subs as of recording this video so I just wanted to say thank you to everyone that has supported me thus far and I can't wait to make more videos for you guys lastly if you want to learn more about game development or chat with other aspiring game developers the code things community on Discord is a great place to do so also specifically for this video I'll be leaving the animation I use for the hand while moving in the wall to be downloadable in the resources channel in the Discord but I'll also be recreating it here with you guys now anyways the link to join is down below but anyways this will be somewhat of a longer tutorial so let's get right into it the first thing we want to actually do is go to window go to quickel Bridge and actually get some type of wall that we can use um for us going through the wall so the first thing we want to do is make sure you're logged in or signed in so I'll sign in right here great so now I'm signed in I'm going to go to 3D assets go to building I believe or no not building we're going to go to Interior then after interior we're going to go to wall and you can use any of these and I mean I've downloaded a few but for this tutorial I'm going to be using this wall right here the modular interior wall we're going click on it make sure we go to a certain quality I'm going to choose nanite and since I already have it downloaded I'm just going to press add great now that it's added what I'll do is I will press shift control and S and that will save all just like so and so now what we want to do is we want to do a couple things before we get into the actual tutorial to ensure that it actually will work so let's go to our first person folder let's go to our Blueprints and let's go to our interact interface once this loads let's open up our interact interface go to our on interact go to our on interact right here and let's change our character right here the variable to be instead bpor first person character we can compile and save this and we can test it by going to our actual character like so go to our event graph let's go to our interact right here and we need to change it just from this to just being self let's make sure that this is the interact interface yes it is so now if we compile and save like this it should be good if you don't already have this interact code um I can go over it somewhat quickly just showing what it does and maybe you can pause the video and go over it but I also have a video going more in depth if you guys would like to see that great so now let's move on to this tutorial one thing we want to do is in the bottom left let's go to our variables and let's create a new variable we're going to call it is in puzzle and we're going to be using that for what we call the obstacle for our door or you can call it is an obstacle it doesn't make a difference after doing this we're going to want to make sure that we go to our I aore move our input action right here and we can disconnect this triggered right here because when you go through the actual door you're only moving in one axis so we're going to want to make sure that we limit it to only one axis so let's go off of this and let's actually do an if statement so we can create an if like so and we can drag this out a bit just so we can clean it up let's move it like this and let's go off of true to right here we want the condition to we can drag in the is in puzzle and just do a not pull so if we're not in the puzzle then we're going to be moving as we normally do like so but if we are in the puzzle then we'll be going off of this false condition the false condition is basically just going to recreate this Left Right mechanic so we can copy that and duplicate it down here we can go off of the false go to a reroute node like so and go straight from the reroute to the add movement input we can press Q to line it up a little bit nicer then after this we're going to want to go to our character movement so let me just move this back a little bit more um we can get our character movement um character movement and maybe get character movement and scroll all the way down here it is we want to get our character movement and we want to set our Max walk speed to be something slow I would recommend 50 that's what I used in my previous version of this so I will do 50 for this tutorial after the is you can compile and save and that's actually all we need to do in the BP first person character as of right now so we can close this we can close the interact interface and we can close the quickel bridge now we're going to want to be actually recreating our bpor obstruction wall That's the wall that we're going to be having so let's go to our first person let's go to Blueprints and let's create a new blueprint blueprint class of type actor and let's call it bpor obstruction wall let's open this up and dock it like so um the first thing we're going to want to do is we can go to add a couple of variables that we're going to want to need so let's go to add a variable let's do is in first Cam and that's basically going to tell us if we're in our first camera obviously and then we're going to do the same thing for is in second cam these are two booleans we're going to have to need those um in order to check and see what camera we're in it makes it a little bit easier for us after this we can go to our event graph and let's actually get a reference to our first person character cuz we're going to need that multiple times throughout this tutorial so we can cast to bpor firstperson character we can for the object get player character and then off of this value we can promote it to a variable like so and we can just rename it first person ref which is a good way to remember exactly what it is we can go over these press Q um we can move that up like this and maybe move um this variable or this little function back a little bit and we can compile pile and save great so now that we have this let's go to our class settings let's go to our Implement implemented interface excuse me and let's add our interact interface like so or whatever yours is called we can then compile and save and go to our interfaces right click and Implement event now that we have this event we're going to need this we're going to need the event tick later on so we can just organize them like so put them in different areas and we need to do that and we can get rid of actor begin overlap and we can start actually working on all the components that we need for this so the first thing that we need is getting two static meshes so let's get a static mesh and let's call it wall one and let's get another static mesh and let's call it uh wall two um we can make it so they're not children of each other make them so they're independent and like that and then so after we have this we can go to our viewport we can start setting the actual um location and transform for it so let's set our wall one to be at NE 19 195 and set it to be95 and set this to be 90 of course after this tutorial is over I you guys can change these values to whatever you would like but I recommend for now to follow along with this after this we can make it a little bit easier for oursel by going to our content folder going to our Mega scans our three assets and the one that we downloaded earlier we can click on the static mesh go back to our thing and press this little arrow which will bring it in like so now we have it we can compile and save now we want to do the same with our wall two so let's click on our wall two and let's do the same exact with the transform that we're going to want to need so let's make sure that we set our x205 set the Z2 or Y to5 and then set the Z to 90 like so and then make make sure that the rotation is 180° and then use the same exact static mesh so you can see this is a very small gap which is kind of what you want for your game cuz you don't want them to be able to walk through the Gap normally so you want it to be kind of small great so now that we have this we can compile and save and for now let's just get this blueprint let's go to our first person our Blueprints and this obstruction wall let's just drag it in like so now that we have it like this let's move it up so it is all the way to the ground right and so we can add um I didn't add this in the actual blueprint but you guys can since this mesh doesn't have backsides we want to make sure the lighting is correct so we can just add uh basic cubes so let's just grab a cube like so and size it up to make sure that it matches the actual wall so let's just do it like this great and then let's move it upwards so that it matches the length of the wall that looks about right so we can duplicate this and enable snapping so we can put it on the other side just about right and then we want to do the same exact thing um for the top portion so we want to make sure we also get a roof um to show off the flashlight effect that you guys seen in the beginning so let's grab this and let's rotate it like so just so that there's a roof and just so that there's no lighting going through um just as a makeshift way to do this great so now that we have it set up like this let's go back into our obstruction wall and let's now we need to actually add some of the components that we're going to want to use so what we can is we can go and add one box Collision so let's add a box collision and we're going to call this box Collision one we can add another box Collision so we can actually click on this and duplicate it and call this box Collision 2 and let's get some of the transforms so we have them set up so let's go to box Collision 1 we're going to want to set the x to be -00 we're going to want to set it uh the Y to be -50 and the Z to be 35 and we want the scaling to be 1 1 and four so that it's tall like so we want it to basically be on one side so then when they walk through this something happens basically what it's going to happen is it's going to fade the camera and it's going to change it from being the camera right here to the actual first person camera again great so now that we have this we want to do the same but for box Collision 2 so for box Collision 2 we're going to want to set it to be35 the Y is going to be -50 and the Z is going to be 35 like so so you can see this and we're going to do the same exact thing 1 one and four on the Z for the scale so now we have two boxes like so and they're at pretty much equal distances towards the end respectively um so now we have this box and that box correct yes great so now we're going to want to add a couple of more components so let's add um let's actually compile and save and let's go to our BP uncore item cuz it's going to have the interaction um icons that we have right here we're going to want to add those same exact ones so what we can do is let's bring it over here like this and we can copy all of these go to our obstruction Mall go to our event graph and let's find a spot to put them so we can just go up here and paste them like so let's move them in and it'll make it easier for us all we need to do is grab these icons so you can click on this one hold shift and then click on the last one once you that you can right click and copy let's go to our obstruction wall and we can paste it like so so now that we have this all of this is actually set up we can just compile and save but we're going to need to do this for the first sphere and for the second sphere because if you want to go from this side it's going to be different than if you want to go from this side so let's start adjusting that now we can go to these two since they're the parents actually let's just highlight everything just in case let's move this to be over here like like so so just make sure that it's centered make sure that it's at a good height that you want um this is pretty good for me but let me just make sure and double check with the other transforms really quickly great yes this is all the right transforms so what we can do is we can rename these to be uh let's just add the number one at the end so we can stay coherent with all of them so let's just add the number one outer interract icon one and then iner interract icon one um you guys are going to see the reason for this shortly why but we could just do that now and we can also duplicate all these again so let's uncheck uh snapping let's duplicate them again and let's make sure we get all the ones that have the one at the end because that means they are duplicated um so actually what we can do is we can get the outer sphere uh Collision one with the one at the end and this outer and we can make it apparent like that and let's rename it to be two rename this one to be two so now that one is correct and then we need to do the same same thing with this one so we can grab this put it like so and we can do the inner two and make sure this one is also two great so now we can grab all of these and we can move those oops we can move those to be on the other side so since this is the second side we're going to be moving it like so just move it to be right about there um there is okay so we want it to be dead center just so we know where to interact with so we then can compile and save and lastly most importantly um we're going to need some cameras and then also some arrows so let's add our cameras first there are a lot of moving components to this that's why it's important that we make sure everything is correct so let's now add our camera so we can search up here and look for a camera like so and let's call this camera camera 1 and let's add another camera like so and we can call this one camera 2 and make them not children of one another let's make them independent and let's set the location and rotation um like I said previously I recommend you guys use my rotations for now and then change them as you would like afterward so for camera one let's change the location to be 173 and let's change the y direction to be - 53 and the Z direction to be 60 great so now let's change the rotation let's just change to 120° so now you can see it's pointing in this direction and basically we'll have this type of view as we go in similar to what you seen in the beginning so now that we have this let's change a couple of things really quickly let's just change the field of view to be 100 to get that same effect um and then now let's do the exact same thing with camera 2 so now that we have camera 2 let's make sure that we add a similar transform but on the opposite side so let's do 170 6 um or excuse me- 177 for the X let's change the y direction to be -43 and let's change the Z direction to be 60 as well now we just need to change the rotation so let's make it 305 like that and as you can see this is a very similar effect on both sides um to get the effect that we are looking for let's change the field of view to be 100 great so now we have that set up we need to then add what is the flashlight so let's go to camera one let's add component let's add a spotlight great and this will be a child and so we can grab this Spotlight and let's change this one so then we can actually copy it and uh apply it to our camera to as well so let's make our spot like this let's make our intensity 2500 you can also adjust these as you would like um let's make the outer cone right here let's make it 46 again you can obviously adjust this as you would like um and now let's apply the rotation so let's make it -4 let's make it six and let's make this -20 and let's make the rotation all zeroed out like so so you can see it kind of goes from the camera and so it'll look like this as you're going through um it's a pretty cool effect but of course again you can change that as you would like now I recommend copying this one so we can just call this Spotlight one just to be coherent let's copy this go to camera 2 and paste Spotlight one um it doesn't actually make it a child but what you can do is just drag it onto it like so then let's call this Spotlight 2 and let's change some of the settings so let's make sure that we have the same intensity same outer cone but we're going to want to change um the location and everything like that so let's change this to be 1 point or let's just change it to be two let's change the Y to be 5 and let's change the Z to be -6 and then let's change the rotation to just be 5° like so and as you can see it's a similar effect just on the opposite side we're also going to want to go to these spotlights and make them both not visible like this cuz we're going to be changing their visibility um in the actual blueprint itself great so now only a couple things left all we're going to want to do now is make sure we have some arrows which will be kind of our teleportation how we teleport throughout the blueprint so let's add an arrow so let's go Arrow add one arrow and so we want one of them to be the start uh Arrow one then we want another to be start Arrow two then we going to want want to be leave Arrow one and leave Arrow two like so and we're going to start getting some of the transforms right now so for start Arrow 1 we're going to want to make sure the X location is 175 not 1,000 um make sure that the Y is -60 and for the Z you can keep it at zero um and we're going to want to change the rotation to be at 90° like so so it's facing that way that basically makes it so your character is spawning right here and he's facing towards this Arrow um kind of similar to where he's facing with this camera it all aligns that way um now we're going to have a similar effect with start Arrow 2 so for start Arrow 2 we're going to want to make sure the location is60 make the um y value -40 and then make the rotation 270 which is 90 + 180 so it's in the opposite direction this way we can then go to leave Arrow 1 and let's make sure that the transform goes as follows we want -260 -50 and then zero for the Z and then make sure that the Axis or the rotation is 180 so it's facing outwards this is where your character will spawn we're going to want um a similar thing for leave Arrow 2 for leave Arrow 2 we're going to want to make sure that we have it as 220 for the X -50 for the Y Zer for the Z and then 360 for the rotation you could also leave it at zero 360 and z are the same in terms of that so you can keep it like that then you can compile and save now let's actually scroll down a bit to find our variables once again and let's leave them um let's put up the component so we can see it let's actually put um categories just so they are a little bit more clear so this has to do with our cameras so we could just do a camera category for our variables and we can put it like so and then this will be our references so if you're going to add references in the future you can add them to that references um category great so now that we have this let's start working on some of our events so one event that we have to take care of is similarly to how we have um the outer sphere Collision one and inner sphere Collision one taken care of we need to do the same exact thing but for um inner and outer sphere Collision 2 so we can copy all of this and actually do c as well to put a comment on it let's make it so show bubble when Zoom so it shows up like this cuz there is going to be a decent amount of blueprints in this um tutorial so let's just call it um Collision One interaction um and let's make sure we spell Collision right collision and then we can move it over a bit and for some reason these did not follow so we can fix these nodes like so make it a little bit bigger great so now let's do the same thing so we can do that but we can actually copy all this and paste it over here and we can copy this so that it is now called um Collision 2 interaction and we'll just make it icons just so it's a little bit clear because there is going to be some interaction here so let's just name this one as well at the end icons great so now you can see these are custom events we're just going to want to delete these custom events here as well and we're going to want to make sure that we actually use them as overlap so we can kind of just reference these to make sure we have the same one so we're using on on component begin overlap for inner sphere Collision one so let's go to our inner sphere Collision two instead right here and we can right click and we can go to add event and begin overlap so let's get that and let's drag it up to be this top left one so we can drag it right here make sure that it's going into that branch and make sure that your other actor is going right into that select now similarly this is going to be the end overlap so let's go back to our inner sphere Collision 2 go to our end overlap grab that bring that over and we can then connect it just like we did previously so just bring that up go to other actor um or you can kind of just do this I don't know how I had it before but your other acture just can go there and it could be just like that and then we need to do the same thing for this one so let's go to our outer sphere Collision 2 right here ad event begin overlap and then do it again and we could just do the end overlap as well just to drag both of them at the same time let's bring them over here so let's go bring this one this one will go to our bottom Branch so we can do the other actor like so and then let's bring this one like this bring our other actor like so so we have our um outer sphere Collision 2 our outer sphere Collision 2 um on this right side and then the inner sphere Collision 2 and the inner sphere Collision 2 to handle all of our um interaction icons so if we go into it now and if we press play and if we go over here once we go in it should be working but there's probably yeah it's working on this side um but is not working on the other side so let me figure out that reasoning for that right now ah the reason for that is because we didn't actually change the interact icons right here we're still using interact one um so we also need to do that for the Collision 2 so for the Collision 2 we're going to want to grab the outer interract icon 2 everywhere you see outer we're going to re um we're going to change it to that so you can hold your left control go over it and just let go and you can see that just changed it to two so let's do that everywhere that we see um outer inter icon 2 make that to and then let's go over here and make this one the outer act or outer interact icon 2 and that time it didn't work but it's okay all we have to do is just put it right into the target um outer interact icon 2 change it like so and great so now that works and now we need to change the inner interact one to be inner interact 2 so we could just go like this go like this and compile and save so now if we go in and if you go like this now you can see that it works perfectly all right so now I'm just going to make sure that this um these Cubes at the end are not overlapping our wall just so that we don't have any weird um camera glitches so now it seems like it's all good let's go back into here let's compile and save so now now that we have our Collision interaction icons taken care of we need to actually get into some of the um real events that are going to be handling some of this camera fading some of the um inter action with the obstruction so let's go off of our on interact and let's actually start dealing with this here so what we're going to be one doing um is separating this into two different sections so there's going to be one section for if you're going into the Collision one and then if you're going into the Collision 2 cuz obviously those are two different um interaction events so let's go off of our um interact and immediately get a branch so we can determine which one we're actually doing let's go off of our our condition and one easy way that we can handle this is we could do is overlapping actor and we can make the actor the close or the um the inner sphere Collision uh one so we can see if we're overlapping this inner sphere Collision we can press Q to make it so it's lined up like so and then make our other actor the git player character like so we can press q and then put this one up a little bit so we can see great so now that we have that let's move this over a tiny bit so so again this is just to differentiate whether we're in the inner sphere Collision 1 or inner sphere Collision 2 so what we're actually going to do is we're going to go off of this false and we're just going to ask are we in the inner sphere Collision 2 now because if we are then we're going to want to do um all the events orchestrated for the inner sphere Collision 2 but if this is false then we're not actually in any of the uh the Spheres which we don't want to actually do anything then if we're interacting and we're not in any of those spheres so what we can do is we can go off of um this true and we can start handling some events the first thing we're going to want to do is grab our camera one and we're going to actually want to activate it because even though it might be activated right now after we disable and enable certain cameras we're going to want to make sure this one is activated so that it automatically knows by default to activate it after this let's make sure we actually set our capsule component radius and that's why this is so perfect we can um go off of this and we can get our capsule component specifically um so let's make sure we clean this up a little bit so what we can do is we can get a little reroute bring it like so just like this and go off of this and just set capsule radius like this let's connect it like so we want our radius to be something small because this is a small Gap I may M 10 but obviously you can um test yours and see maybe how small of your Gap is and what you actually need your radius to be after this we want to make it similar to Resident Evil where if you um are interacting with it you can no longer move like in that little beginning phase so we can just disable movement off of our character movement so let's plug that in like so go right here and we can press Q on this again to make it so it is straight um after our disable movement we're going to want to do the same thing but for our looking around so let's make sure we um set ignore look output or uh input excuse me and so we can do that right here if we uncheck that filtering um and the target for this is the controller object reference right there as you can see so we're just going to want to get player controller and make sure if you have this unchecked from the last step or from this step um you don't want to do player State you're going to want to contact sensitivity again and just make sure you check that one instead and also make sure that you actually press this Boolean to be true you can compile and save but we have a lot more to go so right now is when we're going to actually be wanting to fade the camera but we don't have a direct function that makes it easy for us to fade the camera there is one function but we're going to actually be utilizing that in our own function to make it more um customizable for you guys so you guys can set a fade timing and everything like that so what we're going to do is we're going to go to a clear space let's actually make some of this a little bit cleaner let's comment on this and let's just do begin play and we can show bubble one zoomed so we see it like so and let's move it up a bit great and then uh what we're going to want to do is we're going to want to get a clear space and let's start actually working on this functionality so let's get a custom event over here here we can call it fade camera and off of this fade camera we're going to want to go to start camera fade um you might not see it right here but it is right here in the player camera manager so what we're going to want to do is go off of this target bring it as a pin right here and we're going to rename this pin to camera manager great so let's add another pin actually so this from alpha we're going to make sure this is zero we're going to make sure the two alpha is one because we're going to go from clearness to Blackness right here this color right here and then we're going to make sure the duration gets added as a pin and we're going to name this to start fade time um you can also call it start blink time it's kind of like a blink but if you want to call it start fade time that's perfectly fine um we're just going to make it so we can customize it in the actual custom event when we call this so then let's add a delay node and we're going to then add this duration also as a pin so we can go right here add this duration and let's just call it duration between so this is the duration of your actual fade so you can then change that and then let's also then start camera fade again so we can copy and paste this go from there go right into this so that the target is the same as the camera manager then we're going to want to go from alpha 1 to to alpha0 and we can make this duration similar to the last one put it right into here and let's change this um float value this float input name to then be um end fade time so that we know when we call this custom event what we're going to end it to let's make sure that we also hold when finished right here for this camera um fade this start camera fade cuz if you don't do that it's not going to actually hold it's just going to then do the delay and then do it again so you want to make sure that you hold when finished so it stays dark for this duration cool so we're going to go compile and save and go back to where we were so we can call this start fade or what do we call it what do we just call that we call it fade camera so let's just call it fade camera call that event and for this we're going to want to get player camera manager which is a pretty simple node just to get that camera manager let's make the start fade time 1.5 we can make the duration whatever you would want actually I think I made this .5 let me go make sure and reference it really quickly yeah so I actually made this 1.5 and then I made the end times as well 1.5 and then I made the middle duration between to be two but again you can change these however you would like then we're going to grab a delay node for those 2 seconds in between so you want to make this delay between and this delay the same exact time so that it's dark when you see all these changes you don't want them to see any of these changes so we're going to actually play sound at location um and it's going to be the flashlight sound that we used in the previous tutorial so if you don't have that sound um feel free to follow the tutorial over there and find out where I did it or where I I got that sound from I might have actually linked it I don't really remember but if not you can always find a sound for the flashlight um on freesound.org um so let's just go to our flashlight on sound effect like so and for the location we can just get actor location and then off of this get actor location we can get our first reference to our where is it our references to our first person camera so we can go right into there press Q to make it a little bit straighter and then make it so it's all evened up like so after this we're going to want to go off of our first person reference let's create a reroute note because we're going to need this in a second and let's what we want to do is we want to get our is in puzzle so let's get our is in puzzle and we're going to want to specifically set is in puzzle to be true because now we're officially in the puzzle um we're going to be in the obstruction wall so we can set that to be true and then after this we're going to want to set the visibility of the spotlight one to be true because that's the side that we're in currently so set visibility um and instead of having to do it like this what you can do is you can just find Spotlight one right here and you can set visibility and this is why we had to make sure that the visibility was off by default for one you don't want it to be seen um in the level um but for two we can easily just change it like so um with blueprint nodes so we can set the new visibility to be true um and then we're going to want to actually teleport our player so this is how we teleport our player what we're going to want to do is we're going to want to go all off of this first person reference and let's set World transform and we're going to want to do it of the root component so let's see if we can find that instead actually what we can do is we can just set World transform and we can do it of anything and then we can um get rid of this and then go from the target to be the character and as you can see it made the root transform come like so and you can this pin to now get location rotation and scale so let's connect it like this and let's just add a reroute so it's a little bit more clean um to look at for our code and more readable so let's if I can get this one jeez um go straight from here to here so it's all straight like so and let's bring it over here actually great so yeah let's just do that one more time grab all this press Q great now that we have that we're going to want to make sure we have our location and rotation actually set so this is important so we're just going to want to grab our start camera one or start Arrow one excuse me so let's grab our start Arrow one let's find that and we're going to get World transform and make sure you go to the function not the message um and let's make sure that's queued out and then we're going to want to split this as well so we can see the location rotation and scale that it's using um we're not actually going to be changing the scale so we can leave that at 1 one and one but the rotation and transform or the rotation and location excuse me we're going to be using so we can just bring this over like so not much more now just stay with me so now we're going to want to make sure that we set the actual control rotation so we can go to get player controller and we want to also get the player character make sure you have both of those right next to each other and then what we can do is we can just set control rotation off of the set player controller then we want to go off of the set player character and get actor rotation off of this bring this return value to the new rotation just make sure you do that just so you have it set up like so you can clean it up a little bit like that um now we want to actually utilize the camera variables that we have right here so let's get the is in first Cam and let's press oops let's press alt bring it on and set it as true the reason for this is cuz now you're officially in the first camera um so you should be seeing out of the first camera because you're in the obstacle at the first Arrow location the first start Arrow location so let's make sure that what we're also doing is we're deactivating the second camera so let's go to our camera 2 and let's just make sure that's deactivated just in case it is activated somehow um and it didn't get unactivated or deactivated previously so we can just deactivate like so and then let's actually set the view Target so let's set view Target with blend and if you don't know this is how we actually change for the camera to go from um our main character to the camera utilized right here so let's go to our event graph and let's make sure that our actual Target is our player controller so we just want to get player controller and as I said previously we don't want the player State we want to go right here and get the player controller like so and then we want to make sure that we get the camera one so let's get our camera one like right here and we want to use this handy function called get owner because not this one but what you'll realize is you can't plug this right into the new view Target so what you can do is you can um get owner and we want to go up to components grab that one because it turns it into an actor actually which is what we need right here we need an actor so we can go off of this and we can set this to the new view Target you don't need to change the uh change the blend time if you want to you can but I never Tinker with that just because um I don't usually find that it does really anything that useful for us um now we're basically now in the view of the character or the camera so this is good for us we're in the view of the camera so this is what we want um but now we want to be able to move while we're here so let's make sure that we actually so right here we disabled the movement we're going to want to reenable the movement but there's no enable movement so if you go off of this there's no enable movement um and the reason for this is because if you actually look at this what this is doing is it's just setting the movement mode to be none so we want to actually now set the move mode to be something else um so let's go off of our first person character so we can grab our first person character reference right here and let's bring it in and let's set animation mode for the mesh because we have everything parented to the mesh so in our first person character in our construction script you can see that the mesh is actually the leader pose so we want everything to be Children of the mesh so that's why we're just grabbing the mesh right here and we're going to make it so it goes to the mesh it'll go to everything else as well so now let's grab this and we're going to actually want to use animation asset the reason for this is because we're going to actually be creating the animation soon that we're going to be using in the game so we can compile and save and then we're going to want to after this set the movement mode so set movement mode and you won't see anything here but we can just go right here to set this movement mode and we're going to want to make sure off of New Movement we get default and you can go to contact sensitivity might just be default or maybe you have to click on this you're going to want to grab the you know maybe it's off of the first person reference actually so let's go off this and let's go to our character movement so now we have the character Movement we can cue that out to make it all straight off of this now we're going to want to get the default here it is default land movement mode um and plug get it right into New Movement mode you can make this a little bit cleaner like so and this is the first part of your interaction because now there is another side for the uh sphere interaction 2 so for our sphere interaction 2 we're kind of want to uh want to do the exact same thing let's get the inner sphere Collision 1 and let's change that to be inner sphere Collision 2 so we can just hold control go over it and change that um and we can kind of follow the exact same steps so the first thing we're going to want to do similar to this we're going to want to activate but instead of camera one let's activate camera 2 so let's find camera 2 go over it make sure that it's camera 2 now um and then let's go off of this and similarly grab the set capsule component make sure that now is um we can go off of this component right here if we would like to or we can just drag it again I think I'll do that just to make it a little bit more clean so let's move all this down a little bit um and let's go off of our character or you can go off your reference that's why this is also good um and let's grab our capsule component go plug that into our Target cue this out just in case it's not completely straight and let's bring it like so then we're going to want to do the same exact thing so let's disable the movement right here and this one I feel like we can just go like that um and then we're going to want to make sure that we set ignore look input this will be the exact same and the camera fade you can basically do this exactly the same as well so we can just grab that move that over um if you want to Tinker with these settings if you want it to be different fade times from one side like right here versus over here you can obviously do that um but for this case I'm just going to leave them the same um we need to hook this up right here actually so this cuz I didn't realize we didn't even compile it before but this target actually needs to go go to something so you can see right here it goes to the actual character movement component so you can just do that right there hook it up to the character movement component and now it's all good now let's go back and let's make sure that we have um off of this we're going to want to extend and do this delay again so we can just copy and paste that delay um we want to play that sound again so we can play that sound and we can also set is in puzzle cuz those are not changing we can do that again and we can copy this as well but we're going to need to change some of these things up because now we're in the start Arrow 2 for one so let's grab start Arrow two change that right there Spotlight one is now going to be Spotlight 2 so we can move that like so um and then for the Target right here you can see it goes off that root component so we're going need to do that again so let's go grab our reference get the root component we can press Q like so and then go off this and set it right into that Target um after this let's see we're going to want to make sure the set control rot rotation is the same so let's just plug that in like so you can see if you do the first part it's really the hardest part right here after that it's just kind of same thing just making sure you change it to the second camera so yeah this will be is in first cam we're going to make sure it is in second cam we can make sure that is set and make sure that we deactivate instead of deactivate one let's deactivate two right here just in case um it's still running let's go to camera one and let's make sure we deactivate camera one um let's go to set view Target with blend we can just copy that again and change this change camera 1 to now be camera 2 um and make sure that you have everything set up yep it looks like I do we want to set the animation mode again to be for the asset cuz we're going to be creating an animation asset and again if you want the animation asset instead of having to create it uh with me in a couple minutes I'm going to be creating it um I will be linking it in my Discord so my Discord is down below you can join the Discord and you can have it for free but anyways now we have everything handled for our actual um event on interact which is great so what we want to do is we can kind of just separate all this right here to be um we can comment on it and just change the comment to be interaction from camera 1 versus interaction from camera 2 essentially so we can just comment all this and comment and oops click on the actual comment and just do interaction from camera 2 and make it show when bubble zoomed cool so now we have everything set up like so and we can kind of move this out if we want to make it a little bit more straight um we can compile and we can actually put a bigger comment on if we would like to comment and just make this the interact interact act um event right so this is when you interact and we can also show that bubble and so now everything's going to move together so we have all of the interact code figured out now we need to actually handle the event tick which is also a decent amount of stuff so let's actually bring in that event tick let's look up for event tick like so let's move it over right here and let's actually start using it so the first thing we're going to want to do is get a branch to see if we actually need the event tick when we're using it cuz we don't want to draw unne performance if we don't need it so let's cast to our get first person ref and let's see are we in the puzzle so we can search is in puzzle and if it's true then we want to actually use the event tick we want to start um utilizing it in the blueprint so we'll create another blueprint or another Branch sorry excuse me and we'll see if we're in the first camera if we're in the first camera um then we're going to want to make sure that we do a certain things versus if we're not in the first camera if we're not in the first camera that means we're in the second camera so if we're in the first camera what we're going to want to do is we're going to want to actually set the camera one to be following the camera of the actual player so let's grab camera 1 and let's set the world location we can do it like so go off of this off of the true and let's make sure that we get this new location and split that struct into the XY and Z direction we can go and get these values from our get firstperson ref we can get the firstperson camera that we used there I called mine firstperson cam there it is first person camera so we can grab that first person camera go off of this and get the world location as well cue that out to make sure it's straight and then let's split this struct so that we have our X Y and Z here as well so we're actually going to want to do the same exact thing for our um Spotlight as well since our Spotlight is a child we want to make sure it moves with it as well so we can copy those paste it right here and make sure that we replace camera 1 with spotlight one um and you'll see that the value that it's going to be set to will be extremely similar so let's just grab our X put our X in both of these so let's move it down a little bit so we can put our X into this one as well we can get a little reroute node and make sure it's all set up like so um right here the Y and the Z Direction I did make modifications to so that the camera would look correct so you can add these uh same modifications if you would like to um or you can edit them as you please to get a different look so the first thing we're going to want to do is add 10 to the Y value to make it so it's a little bit of a different look let's put that right into the new location Y and then let's grab this and let's put this into the new location y here as well um and let's grab this Z value and let's subtract 10 from this to make it a little bit lower so let's make it subtracting 10 and we can put that into this new location Z and this new location Z here as well it's a little bit spaghetti code but it's kind of obvious it kind of just goes from the Y to the plus 10 y make that go into this Y and this y as well and the same thing here with the Z make that go from minus 10 Z to both z locations as well after this we're going to want to actually start handling how we actually move and stuff like that so let's move this a little bit down right there and let's start handling some of that now so let's create a branch let's go off this branch and get this condition and we basically want to see if we're moving or if we're just standing still while we're in that um obstruction wall so right in here are we moving or are we standing still if if we are moving also you can close the bpor item and the get first person character if we're moving then we're going to want to um basically play the moving animation versus play the idle animation so of course I made certain animations we're going to recreate those in a minute but if you want to create um better animations feel free um so let's first get the first person reference and let's get the character movement so let's get character movement scroll all the way down grab this and of course cue this out make sure it's straight like so um and what we're going to want to do is we're going to want to get the velocity of the character so you can find that if you scroll all the way down get velocity and then from this we're going to want to grab the vector length so velocity itself is a um is a vector but if you want to get the magnitude of a vector which is the speed in this case how fast we're going you're going to want to get the vector length that's the magnitude so if we grab this we can put that right into our condition right here and since we set it up to be 50 we're just going to set this if it's greater than 35 we're going to move so we can set it like so and move all this down here after this we're going to want to put a do once node so that it only does it once um for the animation and that kind of sounds counterintuitive but we don't want it to make sure that it Loops through the animation and it doesn't play it the right way so we just want to do a do once and we want to then do a false and this false we can just put a out for now this is where the animation is going to go and that animation is going to go to the reset but for now we're going to want to go off this completed and play a certain animation but we don't have the animation yet so we're going to create that um in a moment before we create that let's actually handle what happens if we are in camera 2 so for in camera 2 it's kind of uh more or less the same exact thing so we're going to want to Let's actually move this to be in a different location cuz this is going to be a little bit of a tight squeeze so let's move this over here and um while we're over here let's move this over here as well and comment on it and just call it um right here just want to call it like camera fade event and make sure it's show bubble when um zoomed and scroll this down a little bit so we have a little bit more room honestly you might want to move it over even a little bit more cuz I know that it gets a little bit longer and we can just call this event tick and show bubble when zoomed great so now let's start making some of the animations so okay so the way that I made my animations was I went to add right here you can go to cinematics and create a level sequence you can call it kind of whatever you want so you can just call it animation forming or whatever you want and you can double click on this it'll open up the sequencer and all you want to do is um we can actually before we add any track or anything like that let's go to our content browser let's go to our first person I believe it's in our extras our characters our mannequins and our meshes I believe we want to basically just grab this um skm Quinn or whatever one you want so let's just grab this yeah you could just do this so you can just go and drag in the skm Quinn and all we want to do is go to our sequencer add a track actor to sequencer and add the skm umore Quinn might take a second but this is all you really want after this you want to go into your CR mannequin body and press G and you'll see a bunch of these different control rig um movements so basically I'll show you kind of what I did in my other project right now let's see so here is my other project right now all I really did was I put an initial pin for what I thought was a good movement for the hand so um I got that initial movement for the hand and I just rotated it ever so slightly in different directions and back the these um initial and this ending are the exact same because you want it to be able to Loop and be seamlessly looping so um I'll try to recreate that right now as best as I can so all you want to do is go to your right hand and rotate your elbow to be something similar to let me see how I did it I think I did it upward like this and we want to put it up and then we want to put it over and then we kind of want to rotate the hand in a way that it goes up like this a little bit um and you can obviously change this however you would like probably something like this is okay um and again if you want to download the one that I had in the beginning of the video you can I'm just trying to replicate that as best as I can right now so what we can do is we can add this add for all of these and we can change this to be instead I think it's 0. um five but let me see let's change it to be right here if you click on 30 FPS you could change Showtime as seconds so yeah we want it to be 2 seconds in its entirety so then we'll go to 0.5 seconds in right here and we want to add another key frame so you can kind of do whatever you really want um you can rotate it a little bit um maybe move it down a tiny bit um and then make that another key frame so you'll see right there it rotates a tiny bit um if you want to then you can go to one again you can move it up again and then rot rotate it back like this and you can save all of this and I'm just doing this kind of quickly just to show you guys how I would do something like this um let's then go to 1.5 and let's rotate it again and maybe make it more this way if we want to um we can obviously disable snapping move it up or down or whatever we would like and then change this and then go to two and basically for two we want to grab all of the different um keys for one so we can go scroll down make sure you keep holding your mouse and copy and then for two on the 2C Mark we're going to want to paste so then what you'll have is you'll have a movement that is ending and starting at the exact same time um and the exact same animation so great so now that we have this what we want to do is we want to go to save firstly and then right click on the skm and we can um bake animation sequence go to our animations folder um we can do it anywhere in here but I'll just do um we could do anything it could literally just be squeeze or obstruction you can do UE e5or obstruction animation right and so now all you want to do is press okay just export and so now we will have that once we go to our first person animations and you can see it's right here so if you go into to this we have our animation and it's moving ever so slightly and again if you don't like this you can always change it to however you would like um I'm pretty sure in my version I Chang this rate scale to be 0.5 so it moves just a little bit slower and obviously you can change this to however you would like this is just to do it a little bit uh quicker another thing we're going to want to do is we're going to want to duplicate this animation and let's call this um obstruction begin begin animation so we're going to want to get the same exact animation and then we're going to want to pause this animation and bring it to the very beginning and right click and remove from 0 to 12 and then again right click and remove from 11 to 49 you basically just want to make it so it's only one animation so or only one um thing right here so just remove all of that remove from one to two so then when you play Nothing Changes that's that's your goal you don't want anything to change you want it to be literally no animation right here so once you have that you can save and that means you have everything set up correctly so let's go back to our obstruction wall let's go back to our event tick and let's start working on this right here after our DU once we're going to want to play animation and off of play animation it's not going to show what we want so we can just untick and play animation like so and we're going to want to get the mesh right here of the actual character so we can get mesh and make sure you have contact sensitivity on or it's is it just mesh or maybe we just make that the target itself let me check right now no we need the mesh so let's just maybe search for mesh there you go it didn't show for whatever reason but we need that mesh right there we can then put that into the target um and we can reroute it a little bit make it a little bit more clean like so press Q just to make it a little bit more clean and the first thing we're going to want to do is we're going to want to make sure that we play right here the actual animation so we could do obstruction animation we're going to want to play the actual animation right here and if for the looping you're going to want to actually tick looping and then for this section we're going to want to do the same exact thing but we're going to want to do play animation and what we can do is just get rid of that copy this put that like so go off of this false make sure this one now is obstruction but this one's going to be the begin animation and off of this we're going to go to the reset like so um and we're just going to want to make sure that we also check looping right here for for both of these and the target again is going to be mesh great so now that we have this let's make the comment go out just like how that one is and we're going to want to do the basically exact same thing but for the camera 2 so we can go off of this false for is in first cam go off of this false put a reroute and off of this we're going to want to do basically the exact same thing so we'll set the world location for actually let's just get both of these um we can copy and then paste and then we're going to want to plug that right in like so we can move it up like this and just drag all these down a little bit just so you you don't confuse it um and maybe even move that over so you don't see a really overlap but now you're basically just going to want to do similarly to before we want to get the world location so we'll just go off of this again and get another world location just so that we don't use the same one it's a little bit clear again we're going to split that struct we're going to make sure the x value is the same so the x value is going to go to both of these um let's move it down a little bit um maybe down a little bit because we're going to want to extend this down um this x value is also going to go into here so we can just reroute this like so drag this down create another reroute drag this down go off this y value you're going to want to subtract right here let's subtract 10 again you can change these values if you would like but for now let's just keep them just so you can follow along with the tutorial let's rewrite that just so it looks a little bit clearer go off with this Z and let's also subtract 10 here so let's go right here subtract 10 and make sure that goes into that Z and also into that Z like so so now we have this part so now we want to make sure that we change this camera 1 and the spotlight one to be camera 2 and Spotlight 2 camera 2 Spotlight 2 as shown and then basically the exact same thing so we're going to want to create another if statement and we're going to want to use this again so what we can do is we can kind of copy this right here and then just uncheck that copy paste like so make sure that goes just like that and then all in the comment like so so now this is your event tick great so that is everything I have so now what we really need to do is only one more thing we can compile and save by the way we need to deal with our our box collisions that we added first in our actual blueprint we need to make sure that we have um some logic so it basically tells us to go from our camera back to our firstperson camera in our player um upon exiting our box collisions so let's go to our event graph let's go to our box Collision one and we can go to add event and end overlap it will put it down here and this is actually a good spot we can move it so it's all aligned like so put this up here so now everything is kind of organized let's move our interact event as well so it's all kind of in the same area so off of our end overlap we're going to want to do what we always do go off of this our other actor make sure that it's equal to our player character so let's get player character cuz we don't want AI able to end this overlap somehow I don't I know they can't actually get into the obstruction zone or the obstruction of the wall but just to make sure we're going to put an if and if it is the character like it should be we're going to want to do more logic so let's create another if and let's see um if we're actually in the first camera because there's a problem if you're in this camera and you go over this overlap which is meant to be overlap by that camera if that makes sense and you end this overlap by going this way it's going to fade the camera so and it's going to actually teleport you back to over here so you don't want that we want to make sure we actually set it up correctly so let's set it up to is in first camera put that condition like so and then off of this we're going to utilize our um trusty function the fade camera function we made earlier our custom event we're going to want to do similarly what we did earlier get the player camera manager and we can set these to whatever you'd like um I found that like 0.3 um 0.5 for the fade time out and the duration between to be two is a pretty good time um for your end overlap similarly to what we did before we're going to want to do a delay but in this one I do a delay of 0.5 just because that's right after this um fade time is over so it's pitch black on the screen so we do5 for that delay and then now we want to do similar to what we did before we want to disable the movement um set the capsule radius set the is in puzzle all of this so it's the same type of stuff just doing it basic in opposite basically an opposite so firstly let's get our first person reference and off of this let's get our character movement so let's grab that like we always do set it up straight then let's disable our movement cuz we don't want them to be able to move because that'll cause some glitches for us so let's just make it so they can't move for the moment after this let's make sure that we set it uh the is in puzzle set is in puzzle to be false now cuz now they're leaving the puzzle they're going back to the character so we can set it up like that let's reroute this just so it's a little bit more clean goes from the first person ref make sure again that we're setting it so that it is false because they're no longer in the puzzle after this we're going to want to go again to our first person reference and we're going to want to grab our capsule component and make sure we set it back to what it originally is if yours is different um set it to whatever it normally is but mine is 35 for radius so we can set capsule radius to be 35 set it like so and now that's all good so now when you move you can't walk back into the actual um divot right here cuz your capsule radius is no longer 10 it's now set back back to 35 um after this we're going to want to make sure we actually play the sound at location of our flashlight turning off so this is another moment where if you don't have that sound you're going to want to grab that sound so flashlight off and so now we have that and again we can just get actor location grab this location plug it in right there we can reroute this and make it all clean put it like so great so now we have that and we need to now make sure that we set the visibility of the spotlight to now be false because we're no longer um looking at the spotlight the flashlight is now off that's why we actually changed this for the flashlight off sound effect so we want to just now set the spotlight to also be coherent with that so let's set the visibility now to be off so that we don't see it in the level so let's do it like so put it like this if you want to set the visibility to be set the visibility to be off excuse me and we need to now set the world transform so we need to teleport our player back to where we want them to be so let's grab our first person reference and let's uh get the root component like we did previously so let's do it like this q and then set the world transform and not this one we don't want it to be a message set World transform to that one up a little bit more the component the target is dis component that's the right one one let's split this struct so we have everything the way that we want to we want to get the leave Arrow one this is the leave Arrow now contrary to the start arrow and let's get the world transform go up grab that can press Q on this to make this a little bit straighter split this struct again so we can grab the location and rotation put the location put the rotation and then make sure that the scale doesn't have to really be set it's already set at one and everything like that so it's all good now we want to make sure that they can move again like look around the map because we set their ignore look to be true so how to make it uh go back just get player controller grab this return value and just set ignore look input and make sure you set that back to be false we don't want to ignore their look input anymore we want them to be able to look around and stuff like that so we're going to return that for them and then we're also going to want to make sure that we set the animation mesh similar to how we did right here where is it right here so we can grab that and grab this if you would like to we can just grab these boom copy and go down and paste like so but we now want to change these from animation asset to animation blueprint put that right in like so make sure it's all hooked up and make sure your set movement component is just like that move this up and all straightened out sometimes they overlap like that but it's all good now and you want to make sure that you set the is in first cam to be false cuz you're no longer in the first camera after you're leaving that box Collision you then want to do the final step which is changing your set view Target right here so you can just copy this oh my gosh I accidentally copied and then pasted it so you can undo that copy it and then go back right here make sure that you paste and you can change it to be right here we just want to change the Target and the new Target we want to we just do this like so we can change the uh Target to be get player controller and then make sure that the new Target is the actual first person reference so let's just grab the get first person reference of course you can also get it from down here um just move it like so and make sure that now we get this out pin and put it all the way back to the actually I don't think it's used here hold on let me check really quickly ah yes it is used here okay I thought I remember that okay so we want to make sure we actually do a do once right here just so it can't be abused and done multiple times we want to make sure we reset it on our terms so let's do that and then off of this reset we want this to be where the set view Target blend resets that and brings it up like so so it's a little bit more clear to read and basically what this does is it makes it so every single time we leave it'll go back and it'll ask the same question again and if it's true that we're in the first camera it'll reset it and um make sure that we can actually use it again so let's go off of this go right here make sure nothing else is selected and just press Q so it's all straightened out and great we're going to want to do this one more time but for the Box Collision 2 so let's just compile and save and then go to our box Collision 2 ad event and overlap right here and basically do the exact same thing so let me just see if we can copy and paste and be on with our day yeah we can just copy and paste so let's just grab this this this and then we can just hold uh left control and go over all of this and copy and then we can paste like so it'll paste all of it right there and we can make all of this go to our Collision 2 make sure your other actor is into that equal sign right there and and all we can move all it up in a second but we want to change these variables as we go along so is in second camera is now what we care about um for Collision 2 and we want to make sure that all this looks good this looks good all this is good still will be off now Spotlight will be Spotlight two so let's change that the first person reference is all good except for the leave Arrow one is now going to be leave Arrow two so we can change that up and then this is all good all good um this is all good is in camera will now be is in second cam it's no longer first cam it's the second cam now and the set Target blend will be the exact same and again it's going to go back to our re set let's move this um actually we'll just move this down just to make it a little bit easier and comp file and save so now if we go to our first person map and if we close our sequencer um we're no longer in animation mode we're in select mode if we go to play and if we go to our person right here you can see that it fades and you can see that we're currently in the actual player which means that we have an issue probably with our player sizing or where we have the camera so let me check that out right now aha so a good way to test this is actually by going um when you press play if you get an error like this or you can see that's clearly not what you want you can go in and you can see um exactly where your character is so you can see that our character is spawning kind of in the center right here which makes me think that our start Arrow one and arrow 2 may be the issue yes they're pointed right here so we want to change them to actually be at the correct location so let's get our start Arrow one and let me get the location for it right now so that they're the same so we want it to basically be 175 on the X so let's change that 175 change the Y to be -60 and change the Z to be zero and let's make sure that this rotation is 90 so we can compile and save that and then let's make sure our start Arrow 2 is also good let's go to our start Arrow 2 and that one seems to be in the right place um great they all seem to be in the right place besides that one for whatever reason it seems like it reset so if we go and play now let's see what happens it fades like it should and then you can see it will go like that and again you can change your hand animation you can obviously change it to whatever you would like and then you can go right here and once you end overlap go back and now you can walk again and do whatever you want um to do again if you want to go over here and go back on it you can press e or whatever your interact button is and now we're in it again we can go back and as we're going through it we can go just like we are now and you'll see that it goes into this and now we're back out here so it works all perfectly everything works the way it should be and yeah so I hope you guys enjoyed this video I hope you um stick along for the ride I know it was a little bit of a longer one but yeah I hope you guys enjoy your day remember leave uh what you guys want in more tutorials Down Below in the comments um and let me know what you guys think about this video and any future ones that I create see you guys later bye
Info
Channel: Code Things
Views: 3,546
Rating: undefined out of 5
Keywords: true first person character, blueprints, first-person perspective, video game, game programming, unreal engine 5, resident evil 7, ue5, resident evil, resident evil gap in the wall, how to make resident evil, unreal engine obstacles, resident evil 8 puzzle, resident evil ue5, resident evil ue5 remake, horror unreal engine 5, resident evil 7 puzzle, ue5 first person tutorial, ue5 first person camera, resident evil passageway
Id: R7BjNFfspFY
Channel Id: undefined
Length: 71min 58sec (4318 seconds)
Published: Sun Jun 30 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.