Dynamic Footprint System Part 2/2 - Unreal Engine 4 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys and welcome back to part two of creating this dynamic footprint system in religion 4. in yesterday's video i showed you how to create materials and decals when and where we want to spawn the footprints in today's episode what we're going to be doing is defining these two materials here so we have grass and snow and obviously as many as you want and then we're also going to be spawning in the footprints spawning in the correct type so if we're on grass we'll spawn in grass footprints if we're on snow we'll spawn in snow footprints and that should be it then done once we've finished that we should be all good so this will be the final part the final episode of just basically spawning in these footprints on the grass on the snow on mud sand rock literally anything that you want any material you have i'm going to show you how we're going to be spawning those in today and defining the different surfaces through physics and stuff like that so i hope you enjoy and i hope you find it helpful what we're going to be doing so again we're going to be finishing off the system right now so then the next step is what we want to do is we want to set up the physics materials so this is how we define which surface the player is standing on so to do this we're going to go to edit project settings once this loads we're going to go scroll down until we find physics here under engine and then we'll go down all the way down to the bottom of this and we can set up our different surface types here now you can see here we have a maximum of 62. i think that is the maximum you can get you can't have any more but i don't see why you should be getting any more than 62 anyway and once you've got that what we want to do is we just want to name our different surface types so as you know i've only got grass and snow so we're going to select non and we'll rename it to what we want so if you've got more you have grass you'd have snow then you can type in mud type in sand and like that you just add all your different surface types that you want in here like so so there is no specific name you need to give this it's just the one which makes most sense to you and remember how you spelled it and what you named it as we'll need to access it later on so once you've done this we want to close that and we want to create these into actual physics materials so we go back to content my footprint system and the materials here and actually now i'll do this in formats so i'm going to do is i'm going to right click go to physics again and now we want to go to physical material select physical material like so hit select i'm going to name this one grass underscore pm for physical material and i'm going to duplicate this for however many i have so i've got grass and i've got snow so now i'll rename this one snow pm as well so again do this for all the different ones you have once you've done that we're going to open them up and you see this one is snow pm so under the surface type down here i'm going to change it from default to be snow save that minimize close that i will open up my other one so i've also got grass change the default to be grass so what we've done is we've created our surface types and we've also created the physical material as well and we're setting that to be the surface type that we want i think save and close that as well so now what will happen is whatever we set this on it will be that so let's also set these as well so i'm going to open up my grass and snow materials here which are these ones which i've placed down so the ones in which i want the footprints to spawn on so open those up like so now you can see that if we deselect everything down the bottom left here we have physics material so i want to do is change our physics material to be the one we want so for me that's snow pm i'm going to save and apply that if i close this go to my grass i'll change the physics material to be grass pm save and apply that as well so now what's going to happen is when we are walking on this material it will be considered a physics material now so it will be that surface so if we are walking on top of grass the system and the code will know that this is a grass material and this is a snow material or physics material sorry so that we can then access this later on when we want to spawn a specific footprint so now let's actually code in the spawning so we've done where we want to spawn it when we want to spawn it what we want to spawn it on now let's do spawning it so for this what i'm going to do is i'm going to open up my character blueprint again so i didn't close it so this is again my third person character we're going to go to the event graph scroll down here and find some empty space once we're here i'm going to right click and we're going to add a custom event and i'm going to name this one footprint r or spawn footprint r or spawn right footprint anything which makes the most sense to you out of this i'm going to come out and we're going to get a line trace by channel so this is going to draw a line for us so we can see which surface we're on the start what i want to do is i just want to right click and get actor location so get actor location like so the return value going in the start like so and then i'm also going to come out this return value as well and get a vector minus a vector like so x and y is zero z i'm going to put as 100 and plug that into the end like so so what this is going to do is it's going to get the actor's location so you go from the center of the player and that'll be the start of the line and it's going to draw a line from that all the way down 100 units on the zed so what's going to do is draw a line from the player's location to the floor and so if it hits the floor it will fire the code if it doesn't hit anything then we're probably in the air so it's not going to fire off this code you can also do this by getting the x rotation getting the up vector and timing that by minus 100 but this way it's just a little bit more efficient and a little bit quicker for us so in here what you can do is you can set the axis to ignore i'm not going to bother with that the draw debug type you can set as 4 duration which is just where you can see the red line that's drawing so we do this for testing but i'm not going to worry about that as i know this works so i'll leave that as none so we don't see anything after this what i'm going to do is hold down b left click to get a branch plug that into the execution there and the condition is going to be there to return value so if it does hit something or not if it doesn't hit anything it will come out false and it won't do anything if it does hit something it will go out true and fire off this line of code we're going to make in a minute after this all we also want to do is come out with the out hit and we want to get surface type get surface type like that and the return value of this we want to get a switch on e physical surface like so plugging that into the true and what you can see this is doing is if it hits something which means it will hit the floor it's going to see what the surface type of that floor is so it's going to get the material that we hit and see if it has a physical material of either grass snow mud or sand as those are the physics materials that i set up in the project settings obviously i'm only using grass and snow but i have these as references for you as well now default is basically if we're not standing on any of these so default i'm not going to bother with as i don't want to spawn footprints if we're not on one of these surfaces so after this what i'm going to do is i'm going to set a few booleans so i'm going to make those as well i'm going to hit the plus variable here i'm going to call this one grass question mark plus variable again and call this one snow question mark leaving these as booleans so now if i was using mud and sand i'd also use those as well but i'm not so i'm going to do is off of grass i'm going to set grass to be true and set snow to be false if we're on snow i'm going to set snow to be true i'm going to set grass to be false so basically we are then telling the system which one we are on now again there are different ways you can do this part here but again from all the different methods that i tried earlier i found this one to be the most efficient so at this very moment here it might be a bit tedious having to set all these different booleans however when we go back to the code later on it saves us from having to get a lot of different spawn actors we can just then have one singular one which this then unifies it all under so again do this for all the physics materials that you have now if you want to keep this organized down here as this is in your character blueprint we can give these a category so if you just select default there so select the boolean sorry then select category i'm going to give this one a name of footprints and then i'll select the snow as well and change that to be footprints this means that you can now have this all under its own category meaning it won't mess up with all your other variables in your character blueprint so compile and save that after this what we want to do is this is where we're unifying it meaning this part is going to be a lot more efficient so we're going to come out of one of these sets there and we're going to get a spawn actor from the class so spawn actor from class there and this will also be going into the other set so basically all of these will then go into these booleans and then rejoin again here on the spawn actor so make sure you do it like this the class what i want to do is i want to have this as footprint r as this is my right footprint that we're doing here so footprint r like so i'm going to right click on the spawn transform and split structure pin so i can mess about these values individually the spawn ax location i'm just going to get a reference to my foot r here so this is where we're using this as this is obviously where we want to spawn the footprint is at this plane here i'm going to drag and drop a reference to that come out of this i'm going to get world location so the location of this in the world return value of that will be the spawn transform location like so and then the spawn transformer rotation won't do is just come out of that i'm going to get actor rotation so basically the forward facing direction the player is facing in the spawn transform scale i'm going to set this to be 0.1 0.1 0.1 you can set this to be whatever you like and if you have this to scale anyway you can leave it as one but otherwise my footprint will be quite big so i'm setting it to be a tenth of the size like so so compile and save that so now this is going to spawn in at the footprint what we want to do is we want to actually have this so it spawns in the correct material on it as well so to do that we're going to hold down b left click after the spawn actor to get a branch plugging that in there like so this first branch is going to be the condition of our grass boolean there so if it is grass if it is we're going to come out this return value actually i'll right click promote to variable and call this footprint our reference like that and i'll give this the category of footprints as well i'll plug that in there like so what i'm going to do is i'm going to drag and drop this in here so get footprint ref drag out this i'm going to set material of the decal like so plugging that into the true of the branch there so if this is the grass material we're going to set the material here drag out a footprint rf again and we're going to get grass material so our grass mat variable which we made earlier plugging that into the new decal material there like so i'm going to double click on these as well to get some rewritten nodes to keep it looking nice and organized so what's going to do is if it's the grass material it will set the footprint to be a grass footprint so i'm going to do is offer false of this and hold down b left click to get another branch plugging that in there condition of this is going to be snow now i don't need to do this i can just come out false anyway as i only have two but if you have more than two then you want to do a branch here and it's good practice just do it anyway just in case you want to add more in the future so there's snow we're gonna do the same thing we did here so we can actually just copy and paste that there so we're gonna set the decal material like so this time we're gonna come out footprint r and we're going to get snow mat like so plugging that into the new decal material like that again i'll just organize this a little bit more like so so what's going to happen is basically i'll also just move this over a little bit so what's going to happen is when we call this function it's going to draw a line straight down to the floor if it hits the floor it's going to see which surface we're on if we're on grass it will tell the computer we're on grass if we're on snow it will say wrong snow and then we're going to spawn in our footprint at the location of our foot reference we have there and then it's going to set the material to be either grass or snow or whatever you have now you can do this separately so you don't need to have these booleans here what you can do is you can just have this spawn actor instead and then set the material here but i'm doing it this way instead as it's just a little bit more efficient so we don't have to get a load of different spawn actors on all of these because we have to be setting the material after we've spawned it in we can't set the material here before we spawn it and then spawn it we have to set the material before it so that's why we're doing it this way and again i tried a lot of different ways earlier this seems to be the most efficient so all we want to do is basically just select all of this hit control c control f to copy and paste it down here and then we'll just rename this custom event to be footprint l so this is going to be the left footprint the top one was the right this is going to be the left like so and i want to do is we want to change a few things here so this foot r get well location we want to be foot l get world location the spawn actor we want to change to be footprint l and then we just want to change these references around here as well so actually we'll delete all of this last part like so then we're going to right click on this promote to variable call this footprint l ref and you can just come straight up this return value and get the decal and everything we're doing but this just helps to keep it more organized again plug that in there like so i'll give this the category of footprints and i'm going to do the same thing i did up there so after the true of the grass i'm going to set the material of the decal so set decal material plug in true there and this is going to be the grass material so get grass matte like so plugging that in there like that and then just copy and paste this down here and get your other materials that you have so for me that is the snow mat like that and that is all we need to do so this should now be it done and working but we do need to need to call these but the functions themselves or custom events should be done so again so when it's cooled it will draw a line from the player to the floor see which surface we're on and then it will spawn a correct material depending on which surface we're on obviously i went through it more up here but it's the exact same thing so we're going to compile and save that and now what i want to do is we can close this and we want to go over to our animation blueprint so for me that's content mannequin animations third person and mbp in here we want to go up to the event graph and find some space i'm going to right click i'm going to get a begin play so event blueprint begin play out of this we're going to cast to our character so for me that's the third person character the object will be get player character and obviously this cast for you can even be third first whatever you've named it as third person character we're going to right click promote to variable i'm going to call this one character reference so again we can just easily access this further down here without having to get a load of these blue lines so just underneath this what i'm going to do is i'm going to right click i'm going to get footprint r event nm notify footprint r so the animal notifies we made in the animations when they are called it's going to fire off this event so we fire off this event we want to fire off the other event so we're going to get character reference out of this we're going to call function footprint are plugging that in there like so and obviously underneath this we're going to get footprints l so event and um notify footprint l and then character reference which go into call function footprint l like so plugging that in there like that now this should all be working perfectly so we can compile and save that so when it needs to call it it's going to spawn it in and we've just done where we're going to spawn it all this good stuff so now let's test this out so if we hit play so you can see that if we're walking on this concrete here we don't have anything because this will just be the default so there's no footprints here if we walk onto the snow we're getting these snowy footprints like so and if we go into the grass we get the grass footprints and that works perfectly and it changes each time so it isn't working on this one here so let me see why if i set the material wrong i have yeah i haven't put the correct material on here so this needs to be grass matte like so and now this should work so as you can see it's doing it dependent on the material like so and there we go we can see it working a lot better now so we have the white footprints here so we have the snow we have green for grass here and you should see that they're going to be despawning after us like that you can see that despawning meaning it won't be lagging like so and this works great and again you can either use solid colors like i am or you can use actual textures which i showed you all you need to do is just change just instead of using the constant ring vector use a texture sample it's completely customizable for you there's a lot of different things you can change in here to get it to look a lot better for you and work a lot better and work differently all this good stuff that you want to have but i think that this video is we've done everything we've wanted to do we've created a dynamic footprint system in which when you are on grass it does grass if you're on snow it does snow footprints and you can have as many materials as you want you just do the exact same thing we did in today's video it's very easy and simple to do and pull off for yourself and they also despawn after you so it doesn't lag and this looks and works great so thanks so much for watching i hope you enjoyed and i hope you found it helpful and if you did make sure like subscribe down below so thanks so much for watching and i'll see you in the next one [Music] you
Info
Channel: Matt Aspland
Views: 4,323
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, blender, games design, ue5, unreal engine 5, dynamic, footprint, footprints, foot, print, foot print, step, steps, footsteps, system, change, material, materials, changing, grass, on, snow, mud, sand, dirt, decal, decals, advanced, basic, quick, easy, part 1, part 2, part, playlist, series, prints, snowy, muddy, footstep, leave, ue4 footprints, on ground, ground, right, left, where, when, floor, the, time, texture
Id: 9HlZ-6aFk1I
Channel Id: undefined
Length: 16min 56sec (1016 seconds)
Published: Sat Dec 19 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.