How To Make a Simple NPC - Step by Step (Blender, UE5)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone and welcome back to the channel today we are going to make a simple slime NPC we'll go through the entire workflow from start to finish we'll start with making the mesh and animating it in blender then we'll continue in annual engine where we'll set up the material make a simple AI that roams around and we also make our slime and be able to Blink and finally we'll set up and add some logic to our animations so let's start in blender here we are going to make a little blob of slime and since most of the time slimes are pretty round until you play this game we are gonna start with a sphere then we can use proportional editing by clicking on this button to pull some of that mask down because of weight and gravity applied on a slimy substance after that done we can go and make him a face starting with ice so create a circle with 10 vertices then fill it up now now let's enable snap tool because we want to stick the eye on the surface of the mesh and for that we're gonna need to change the snapping to face then we want to snap on the face with the center of our Circle we also want to align the rotation to Target and affect the rotation now you can happily pull the eye over the mesh for the second die we can just add the mirror modifier now because the snap tool plays the ice exactly at the same position as the faces it created this artifact where the eye and the face are battling or overlapping to fix that we're gonna need to pull one of them out of the fight now for the mouth select the Slime mesh go to the edit mode then select two faces where the mouth is gonna be duplicate those meshes and separate the selection after that we can go and shape them out you can add more detail by adding some Edge loops and also don't forget to pull the mouth out of that overlapping area then you can use proportional editing to make him a little smile and to not make both of the sides of his mouth manually you can delete one side and then add a mirror modifier after you finish the mouth you can merge it with a slime mesh now as you have already noticed our slime uses flat shading which will also be same in annual engine so let's quickly change the shading to smooth let's now add color to easier to distinguish the face from the Slime body in the material properties create your materials one for the Slime and one for his face after that you can select his mouth in the edit mode and assign the face material for the eyes we want him to be able to randomly blink and for that we're gonna use shape Keys now the way shape Keys work is that when you have an object selected you can go to the object data properties and add a new shape key this is gonna be the base or we can say value 0 then if you create another shape key that is going to be our value one so if you have selected q1 go to the edit mode and change the mesh geometry but be aware that you cannot add more geometry it will just wouldn't work so now that you have changed the mesh you can go back to the object mode and play with the value of the shape key what's happening is that blender is interpolating between the location of every vertex between the base mesh and the edited mesh there's one more thing and that's that you cannot use any modifiers after you add the shape key now in the process when I was making this slime I made 1 a mistake when making the blinking and guns is something that doesn't work well with shape keys while it looks fine in blender it will make trouble in unreal so just make sure that the eyes have no handguns so let's duplicate the eyes and separate them from the Slime mesh then delete one of the eyes and add a mirrors modifier after that we can shift that duplicated eye so that it looks like a closed eye don't be scared to scale it up or down now as I said earlier we can't have an n-gon so let's enable snap tool with the same properties we had earlier then duplicate your vertices and add them evenly to the middle of the eye so that they cover each side then switch to the faces and delete only faces now switch back to the vertices and create 6 squats by selecting four vertices at a time and fill them by pressing F now let's do the same to the original eyes after that select the Slime and add the shape key then add another one for the blink now let's enable snapping tool with snapping on vertices and let's snap every vertex from the original eye to the duplicated eye and do the same for the second die after you're done you can delete the duplicated eyes and now if you use the shape key everything should work as intended now before animating we need to rig the Slime and since it is a really simple mesh we're gonna need only one bone so let's add an Acme chair and rename it to something else because it may not work in Unreal Engine if it's called Armature don't ask me why because I don't know why let's take the mesh and then the bone click Ctrl p and select with automatic weights this should connect the mesh with the bone now it will be easier if we could see the bone at all times so let's go to the object data properties and enable in front if you now go to the pose mode and manipulate with the bone you will see that it will only affect the mesh and not the face so let's select the bone and then the mesh and go to the weight paint mode what do you now see in the red is what is affected by that bone and the blue color indicates what's not so let's press M and select the face be sure that the weight is set to 1 and then fill your selection by pressing shift plus K now you have attached the face to the Bone we can now go and animate so go to the animation tab here we are going to add one more window for non-linear animation you're gonna figure out why later in the video now let's change the dope sheets to action editor and add a new action then we're gonna save that action by clicking on this shield first we're gonna animate the idle animation let's change the start from 1 to 0 and now we can add a first keyframe by pressing I and selecting location rotation and scale for this animation I want our slime to bounce on the floor from side to side so let's go to the frame 15 and scale him down on the Z axis and scale him up on the X and Y axis and instead of manually inserting a keyframe every time we make a change we can just enable auto king then at frame 30 you will came back up so duplicate keyframes at the frame 0 and paste them to frame 30. what we want now is to change the timing of our slime scaling up and down I want him to go fast down so it looks like he bounces and then slow on top so let's go to the graph editor by pressing Ctrl tab here you can select everything and then focus on it by pressing Del key after that you can select every single property you don't need and delete it so that it is cleaner to look at now to make him go fast at the bottom that's like the middle keyframes and scale them individually down or we can instead just change them to Vector now to preview this animation select all keyframes and press Ctrl alt P you can then modify the keyframes their speed or even their values their liking now let's make him rotate from side to side so let's go to the first frame and change his Z Rotation by some amount then back to zero at frame 15 and to the opposite side at frame 30. now this doesn't really Loop well so we're gonna need to add a few more keyframes and we're gonna just duplicate keys at the frame 15 to frame 45 and then 0 to frame 60. now you can go to the graph editor and change the timing of the rotation as well but I don't feel like it needs a lot of changing now that the idle animation is done you can go and push it down into non-linear animation window now for the second animation we are going to make the jump Loop so let's move the idle animation to the side and reset the slimes transform then we can insert the first keyframe then duplicate that keyframe to the frame 24. now go to the middle of that animation and move him up to the desirable height for me that's gonna be four meters for example then easier establish the timing I'm gonna set the interpolation to constant then squish him down at the second frame now he is preparing to jump then at the frame 4 he's gonna bounce up so squish him up now because he is still touching the ground at frame 4 we're gonna need to move the middle frame to the right we can now set the keyframes between the jump when he's exactly 2 meters high now these keyframes are still not gonna be exactly in between the keyframes on our timeline because the closer to the ground he is the faster he goes so it's gonna be somewhere in the middle but little further from The Middle keyframe also you can squish him a little bit down on top that's when all of that mask comes together for a second now that our keyframes are established we can go and change the timing even more in the graph editor and while making the animation you can go and push it down into non-linear window and then when you click on it and press tab you can still edit the animation now let's first edit the up and down movement which is y-axis again we want him to go fast at the bottom and slow on top we don't need these keyframes at the middle so you can delete them then we can change the bottom keyframes handles to Vector then we can edit the handles to highlight that movement even more now for this at the start we want them to happen fast no easing in and out we can even move them a little closer to the first frame now the squishing at the top starts at around frame 7 which is too soon because he is not even close to his highest point so we're gonna duplicate this and move them to the right now I have also figured out that it's better if we make the first frame as the last frame and then delete the first frame and then move the whole animation by one frame to the left now because our animations doesn't really blend together well we're gonna need to make in-between animations and in our case that's gonna be jump stacked and jump end so let's start with jump start we're gonna set him to default position and then he's gonna squish down pretty much what we had originally at the start of the loop animation after we changed it you can then preview how these animations work together and for the jump and animation we will stretch him like when he's coming back down then stretching more and then make him like he's going back to that idle animation so he starts at 0.6 in the idle animation that means he will make him go to 0.055 also make sure that keyframes at the start of that animation are set to Vector since he is coming fast to that animation and not slow after all the animations are done we can go and bake them so let's like the first animation and go to the pose animation and bake action and here we are gonna select the length of the animation so basically the first and last keyframe of that specific animation then we'll gonna deselect only selected bones because we want to break all bones and we're gonna select visual King and then we can click OK that's gonna make our animation and we're gonna need to rename it because it changes the name back to action then we can push it down in non-linear animation window and we can pretty much repeat the process for every single animation but for the idle animation we're gonna make the length one keyframe shorter because the idle animation is the only one that has same last keyframe as the first keyframe after that we can go and Export so let's select all of our animations and then select the mesh and then the bone and now let's export as an fbx now for the setting we're gonna use selected objects then we're gonna set the small thing to face in animation and we're gonna disable adding Leaf bones and in the back animation we're gonna disable all actions now let's import everything to Unreal and in the import settings we want to import animations and also in the mesh Advanced we want to import merch to Architects which are basically shape keys but in animal it's called Murph targets then we can import now you may get imported the same animations twice so if that happens you can just delete the duplicated ones now let's make a material instance out of that material and assign it to the Slime skeletal mesh we can bring this mesh to the view part so that we can see how it looks like now we're gonna make the material for the Slime so open the existing slime material here we are going to add a few nodes that will make our Shader now this Shader is originally made by ensuite you can check him out on Art station now I'm gonna modify this a little bit so let's add the world position and divide it with the parameter which is gonna be a noise scale then I will going to add a noise and plug the device node to the position now in the noise we are going to change the function to fast gradient 3D texture and change the levels to 3. then we'll gonna multiply all of that with the color after that we're gonna add a left node and plug the multiply node with the color and for the alpha we are going to add another parameter which is going to be on noise intensity then we're gonna want to have this effect around the mesh of the Slime so let's add the first download and we're gonna plug another parameter which is going to be a personal exponent and we're gonna plug that to the exponent in then from the first nail we're gonna add a chip contrast with another parameter and then we're gonna learn all of this with another color and we're gonna use the first null notes as an alpha after that we can plug everything to the base color we also want to have a use for the MSU channel so let's add a saturate note and then multiply the attribute another parameter which is going to be an emissive power and finally we want to change the roughness to 1. then you can open the material instance and tweak a few of these settings now for the AI we are going to import the third person character and we'll just copy the third person character blueprint it's pretty much the same if we would do it from scratch this way it's just faster if we delete some stuff so let's rename it to the Slime Ai and open it right away delete everything in the element graph and then let's also delete the camera and replace the third person character with our slime skeletal mesh we can then scale him and the collection capsule so that they fit together it doesn't need to be perfect just make sure that the bottom is close together so that it doesn't float let's then go to the event graph and make a simple AI that comes around so let's add a custom event we can call it a random ROM then from that we are going to call an AI move to what we want to move is our slime so find the reference to solve and plug that to Bone now for the destination we want to get an active location and from that we want to get random reachable points in radius then we can set the radius and plug it to destination right now if the AI reaches that destination it will do nothing so what we want him to do is to wait for a few seconds and then repeat so let's add a delay at set for how long he should wait and then call the random ROM event also we need to somehow start this event so find an errand begin play and call the random ROM event in the level editor we also need to add a narrow mesh bound volume to specify the area in which the AI can move now let's set up the blinking so go back to the event graph and add the set move Target now we need to specify the value and time in which the value is going to change so let's add a timeline we also need to set the merged Target's name so I called it blink and it needs to be exactly the same in here now let's open the timeline and add the new float track we're gonna add a keyframe which is going to be at the start with the value 0 then a second keyframe with a value 1 at 0.15 seconds and third at 0.3 seconds and value back to zero this is gonna be the speed at which he blinks you can make it longer shorter however you want we're gonna enable auto place so that it doesn't need to be called it will stack by its own and set the length to 0.3 seconds now let's plug the value from the timeline to the value of the marked Target then we want to randomly call the action again so let's add a delay and to the duration we're going to plug a random float in range and here we will going to specify the minimum and the maximum seconds now to make all of our animations work together and we're going to make an animation blueprint so let's create a new animation blueprint and select our slime skeleton we're gonna go to the event graph and from the event blueprint backing play will cast to the Slime AI then I will gonna make a variable from a slime Ai and this is gonna be our reference then from the event blueprint update animation will ask if every reference is valid now we want a Boolean for if our slime is moving for that we will need to get the speed from the AI so from the Slime area reference we're gonna get the velocity and the vector length now we want our slime is moving Boolean to be true if he goes faster than 150 so that's what works best for me but you can tweak this later now let's go to the anime graph and add a new state machine and from that you can add the default slot and plug that to the output pose let's open the state machine and we're gonna add the New State for the idle jump start jump Loop and jump and animations which are gonna be connected in order now for every state we are going to assign a proper animation now we are going to need to add some logic to these animations exactly how they should transition between each other so let's start with the idle animation to jumpstart animation here we are just going to transition if the is moving Boolean is true then from the jump start the jump Loop animation we're gonna ask if the time remaining from the jump start animation is less than 0.1 and if it is it will transition to the jump Loop animation now for the jump Loop to jump and we will gonna ask if the East mowing Boolean is not true and also if the time remaining is 0.1 and from the jump end to idle animation we'll just gonna transition if the time remaining is again less than 0.1 seconds we also need to be sure that our animation blueprint is assigned in our slime AI blueprint now lastly I have this back where my slime is doing this weird thing where it is in idle animation and that's because my idle animation got exported with one more extra frame at the start that shouldn't be there now I can just easily fix that if I set the animation length to send range and then set the length of that animation excluding that extra one frame and then pressing green import and that should fix it thank you
Info
Channel: Marpy
Views: 21,091
Rating: undefined out of 5
Keywords: Game Development, game dev, indie game development, unreal engine, unreal engine 5, ue5, blender, blender tutorial, blender 3d
Id: QfIDdDExwOk
Channel Id: undefined
Length: 25min 4sec (1504 seconds)
Published: Fri Sep 23 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.