First Person Footsteps | No Mesh Or Animations - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to another engine 4 tutorial in today's video i'm showing you how to do footstep sounds in first person so i've already done a basic footstep sounds and a dynamic system so it's different on different floors and materials however they're both for third person so today's gonna be first person by which i mean if you don't have a mesh or animation to do the other versions with this one will work for you so we don't need animations in this one so let me show you what it's going to look like so it's very simple so we get in we walk around you can hear we have footsteps and if we jump we land we get the photos when we land but not when we're jumping so this is going to work for us today this is what we're making so let me tell you this code and i'll show you how i've done it so what we're going to do first is we want to create our footstep sound effect so i've got four different sound effects off freestand.org which i'll leave a link to in the description down below and these are what they sound like and you can just use one as well however i only have multiple just so it sounds a bit different a bit more random sounds more realistic so once you have all of them we're going to right click go to sounds and we're going to create a sound queue i'm just going to name this one footstep queue like so and open it up straight away i'm just going to minimize this a bit but so we can still see everything else and we're going to select all of our sound effects and drag and drop them into sound queue here and we can open this up again and what we've got is we now have these four sound effects in this one sound queue we're going to come out of one of them and get a random node and the output of that i'm going to get a modulator and the modulator will go into the output of the sound queue like that and so what's going to do is just going to get a random one of these four sound effects and play that for our footsteps sound so i'm going to add another two inputs so i can put all four of these in like so so again it just keeps it fresh different for the player doesn't sound too repetitive so we can save that and we can close it then to finish off the rest of the code we're going to go into the character blueprint so for me that's content first person vp first person character now what we're doing here is we want to find our movement inputs you can see we have input axes move forward and move right here we're going to be using these so i'm not going to do anything with it at the moment but we just want to write the code next to it so we can easily access it in a second so what we're going to do first is you want to right click and get velocity like so and we're going to right click the return value and split the structure pin and because we want to be only playing this if the player is moving so the return value x we're going to get a float is greater than a float and we can set this to something small for example two out of the x again we're going to get a less than so float is less than a float and we're gonna set this to be minus two so if we're moving forwards or backwards and we're going to do the same on the y's we just duplicate those down here and plug them into the y instead keeping the values the same as we want to see if we're moving forward or backwards on the x or y now we don't want to play it when we're jumping because obviously if we're jumping we're not walking on the floor so we don't want to play the sound effects so to do that we're going to come out the return value of the z and get an equal equal and having that as zero now we'll move that down a bit and for these top four so the greater than and less thans we want to come up with one of them and get an or so an or boolean adding two more pins and i'm plugging all of these in like so so if we are moving in any of these directions so it only has to be one of them and then out of that we're going to get an and boolean plugging that into the return value of the equal equal so we have to be moving in any one of these directions and the z has to be equal to zero so we're not moving on the z so that is working for calculating when we should be playing them so we should only play them if we're moving forward or backwards on the x or y and we're not moving on the z so i'm going to hold down b left click to get a branch with the condition being that and boolean there and the input of this branch we're going to go into the add movement inputs here and we're going to go into both of them so when the player is wanting to move forwards or backwards we're going to be firing off this code to check the player's speed so i'll actually just do that just to keep it more organized like so and then we only want to fire off the footsteps sound effect if this is true because that's when we're moving correctly so off of true we're going to hold on o left click okay do once obviously plug that to true there and that's because we don't want to constantly fire off the sound effect every single frame that we're moving forwards you want to do a correct input so after you've completed we're going to set timer by event for the event we're going to come up just above it right click add a custom event and we're going to name this play footstep sound so when this timer goes off it's going to fire off this event and we can plug the event in there by dragging the red square into there like so now with the play footsteps sound we're going to play sound at location with the sound being our sound cue that we made earlier so i named mine footstep q there the location we want to right click get actor location and we're going to come out the return value and get a vector minus a vector i'm just going to put 44 on the z and plug the location in there and we're doing that because the average height of characters and the height for the first person character or the half-light sorry is 44 so taking 44 away from their location just essentially going to get the floor position where the feet is so that sounds a bit better so you can just use the location or play sound 2d however this just adds that extra little detail and level of realism in there so that's now going to play the sound effect however what we're going to do is we're going to right click the time promoter variable and name this footstep interval because again this is just going to fire off every frame which we don't want and with it being a variable instead of just putting it straight in it means that if we start sprinting we're going to be faster we can change this to then make it so the footsteps play faster as well and so what you simply do is just in your sprint code you'd set this interval to be something lower and then when you stopped sprinting you'd set it back to be this default value in the default value we can compile and change that and i'm going to set it to be 0.5 you can set it to be absolute whatever you want but i think 0.5 is good for me and the speed my player is walking out and we're also going to take looping so it's always doing this when we want it to but now how do we stop this well what we're going to do is we're going to come to the return value of the set timer by event and clear and invalidate timer by handle so that's just going to simply remove it all stop looping it stop playing it when we don't want to disconnect the execution and plug it into false instead so when we're not moving correctly so in the right direction of speed it's going to stop playing and we'll plug that into the reset of the do once as well so when we start moving again we can replay and redo the sound effects that's the basic footstep system set up however when we jump and land we're not going to get a sound effect so i'm going to do one simple thing to fix that as well down here just underneath the code i'm going to right click and get event on movement mode changed like so out of the previous movement mode i'm going to get an equal equal nm and i'm going to set this to be falling because i only want to do this if we've just landed from falling and out of new movement mode and again equal equal nm once again setting this one to walking so if we were falling and it would land it into walking we're going to do this so we're going to come up one of them get an and boolean plug the other one in there like so holding down b left click to get a branch plugging all of those in there accordingly like that and off of true we're going to call function play footstep sound like so so it's then just going to use this up here to play a sound what we want so again if we are falling and we land into a walking we're going to play the footstep sound effect so now this is it completely done so i'm going to do is just select it all hit c to comment it and name this footstep sound effects or whatever you like and now we can compile save and let's hit play to test this out so you see we landed there we got a sound effect if we stop walking around we're going to get these sound effects at that correct interval like so and if i stop it's gonna stop if i walk and jump we don't get it while we're jumping but we get it when we land so that works perfectly so i think that for this video is we've done everything we wanted to do we set up this footstep system in which we don't need to use a mesh or animations to do it i do have animations here but we didn't use them and so we have it so if we're walking in any direction we have the footstep sound effects we'd like and if we jump we don't get them until we land again when we do get them and now i have got a video on setting up an advanced dynamic footstep system for different materials and floors and surfaces and all that good stuff however again that's third person but that will still work in here if instead of doing the line trace code deciding which footsteps sound to play instead of doing that in the animation blueprint you can just do it in here so you can either right click get a custom event put the code there and then call that custom event here just before the branch that would work great for you as well i've tested that out before and it does work if you don't quite understand it you like me to do a video on that i can do in the future if you'd like however like i say this works perfectly for what we wanted to set up today some people were confused about how to do it with no mesh and no animations so i've made this video on explaining how to do it so thanks so much for watching i hope you enjoyed it and i hope you found it helpful and if you did make sure to like subscribe down below thanks so much for watching and i'll see in the next one you
Info
Channel: Matt Aspland
Views: 6,559
Rating: undefined out of 5
Keywords: ue4, unreal engine 4, unreal engine, tutorial, ue4 tutorial, unreal engine 4 tutorial, how to make a game, how to, 3d modelling, blender, games design, graphic designer, ue5, unreal engine 5, fps, first, person, first person, footsteps, no, mesh, anims, animation, animations, no mesh, no animations, no character, character, ue4 footsteps, first person footsteps, fps footsteps, sound, sounds, audio, loop, looping, move, moving, jump, jumping, land, landing, forward, backward, ue4 fps footsteps no mesh
Id: I973d6ABTf4
Channel Id: undefined
Length: 9min 13sec (553 seconds)
Published: Wed Feb 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.