How To Make A Monster Evolution System In Unreal Engine

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everybody in this video I'm going to show you how to make an AI monster that can evolve this method will allow you to change your character's skeletal mesh and animation blueprint so you're not limited to using just one skeleton as always this is a big inner friendly tutorial that uses blueprints only there's a lot to learn in this video so if you are a beginner I recommend watching it all the way through so with that being said let's jump in we're going to start by making our monsters blueprint right click in your content browser and select blueprint class then create the character blueprint I'm going to name mine monster AI once in the character blueprint you'll want to select the mesh you'll be using for your Monster for this initial setup you're going to want to select the first form of your monster or as I call it the Charmander form click on the mesh in the components panel then in the details panel on the right hand side select the desired skeletal mesh asset move your mesh in place in the viewport next we'll be making a blend space and animation blueprint for our monster depending on how many different meshes you're using you may need to create these items for each individual monster form in the asset I'm using the wolf cub and the adult wolf use the same animations but the werewolf does not so I'll be creating two different sets of blend spaces and anim blueprints right click in the content browser go to animation Legacy blendspace1d [Music] in the asset browser on the lower right hand side locate your mesh's idle Walk and Run animations and place them accordingly in the horizontal access panel [Music] for best practice rename your horizontal axis to speed next let's make our animation blueprint in the content browser right click go to animation and then animation blueprint make sure to select the appropriate skeleton [Music] access the anim graph of your blueprint and look for your newly created blend space in the asset browser drag out your blend space into the graph then promote your speed float to a variable so that we can reference it later on let's add a default slot to our logic in order for our character to use anim montages [Music] next access your event graph cast to your Monster's character blueprint you created a few steps ago plug in the try get Pawn owner into the object slot out of the cast search for get velocity and then search for Vector length [Music] drag in your speed variable we created using our blend space and set it plug Vector length and the cast into the appropriate slots [Music] don't forget to go back to your monsters blueprint and select your newly created BP I'm going to go ahead and change the material of my monster while we're at it now we need to bake a blend space and animation blueprint for every form of our monster that uses a different skeleton in this example I am using a baby wolf that evolves into an adult wolf that evolves into a werewolf as I mentioned before the baby in the adult wolf use the same skeletons so I can use the same animation blueprint I just made for my adult wolf I only need to create one more set of Animation assets for my Monster's final form foreign [Music] next I'll be showing you how to create a user interface that will allow the player to feed and pet their monster using on-screen buttons the UI will also show a level progress bar and what level the monster currently is at back in the content browser right click and go to user interface and click on widget blueprint [Music] thank you the first thing we need to do is drag in a canvas panel for our UI to set on making a good UI is to group the elements within boxes in my UI there will be two different buttons the user can press with labels next to these buttons using the horizontal box I'm going to group each button with their corresponding label [Music] thank you [Music] with the horizontal box selected click size to content in the details panel in order for the elements to fit in the box next I'll group the two groups together using a vertical box and size that box to the content as well foreign [Music] now we can move our elements to the desired location within our canvas by changing the position of the vertical box let's add some padding to the horizontal boxes and a little bit of padding on the right of each button [Music] using these same Concepts I'll be adding a progress bar and two additional text elements one text block will be used for the word level and the other will be for the actual level number [Music] [Music] foreign [Music] [Music] [Music] now that we have our UI set up let's jump over to the monster's character blueprint and begin creating our logic to change forms start by adding three variables of the type integer these variables are going to keep track of our current progression on our level bar the max amount of progress the bar can hold and the level of our monster together [Music] we want to be able to use these variables with our UI that we created a few steps ago in order to do that we need to add a reference to our UI in the form of another variable in our monsters event graph find the begin play event and pull out from the node search for create widget and in the class drop down locate the widget blueprint you created promote the value to a variable name it and add it to the viewport [Music] now that we have our UI as a variable let's create a function to track the level progression click the plus icon next to the functions tab in your monsters blueprint get your UI variable and search for your progress bar [Music] if you can't find your progress bar go back to your widget blueprint and check the name drag out from the progress bar variable and search for set percent drag out from the percent float and search for the divide function get your current level progress and plug it into the top slot and then get your max level progress and plug it into the bottom slot make sure your max level progress is on the bottom or this function will not work drag out from set percent and add a return node currently our variables are set to zero this is fine for our current level progress but we need to add a number to our max level so that we know what number we're trying to reach in order to level up let's add the ability to increase our level progress and do some testing back in our widget blueprint we'll start by naming our buttons so that they can be referenced more easily first change the text in the text block so that the player knows what the buttons are doing I'm going to have one button for feeding the monster and the other for petting [Music] next click on the button and change the name at the top of the details panel [Music] thank you [Music] foreign once you've named your buttons navigate to the event graph by locating the graph icon in the upper right hand corner of the screen in the event graph you should see your newly named buttons in the variables tab highlight each button individually and add an on clicked event to the graph it's important we use on clicked and not on pressed as onpress will increase our level multiple times if we hold down our Mouse button even for a second drag out from the first button and search for get actor of class locate your Monster's BP in the class drop down drag out from the return value and find the variable that tracks your current level progress drag out from that and search for the add function this will add a desired amount to our current level progress so pick whatever number you see fit after adding to the level we want to set that number as the new number for our current level progress now do the same thing for your second button I'm going to add a smaller value when petting the monster versus feeding [Music] okay let's test out our logic to see if it's working drag your monster into your level and click play alright nothing is happening which in this case means we forgot to call our function go back to our event graph for our monster and let's call our function on the tick event now let's try this again okay it's working but it's not quite ready there are a few things you probably notice that need to be fixed one issue is our progress bar is not resetting once it reaches its Max also we want the number next to the level to update once the progress bar resets another issue you may have run into is if you clicked off of the UI your cursor went away we're going to fix this issue by showing the mouse cursor and switching the input mode we'll create an event where the UI will show on screen once the player approaches the monster in your monsters BP add a box Collision under the components panel adjust the size to your liking [Music] foreign for testing purposes I'm going to make sure this box isn't hidden in the game with the Box still highlighted add a begin overlap and an end overlap event which can be found at the bottom of the details panel [Music] for the begin overlap portion of the logic cast to your player's character and plug the other actor pin into the object slot drag out from the cast node in search for show mouse cursor if you can't find it uncheck context sensitive in the top right corner of your pop-up window make sure the box to show the cursor is checked add the player controller as the Target and then set the input mode to gaming UI foreign controller to this node as well if you get an error with your player controller you probably selected the wrong one re-add the player controller but make sure the context sensitive box is now rechecked you're going to want to remove add to viewport from your event begin play as we will be adding it once we overlap the Box Collision finally add the UI to your viewport using the variable you created for the widget this will now add the UI to the screen when the player overlaps the monster's box Collision [Music] we want to add functionality to remove the UI when the player is no longer overlapping with the Box on the end overlap event cast your player character then hide your mouse cursor by unchecking show mouse cursor and set your input mode to game only an important note on the input modes when your input mode switches to game and UI the input for turning your player's camera switches from moving your mouse to holding down the right click on your mouse and then moving it once you change your input mode back to game only you can resume using your mouse only to move the camera next drag out from the node and search for remove from parent plug your UI variable into the target pin [Music] okay now let's address the level bar not resetting we'll need to create a function that resets the bar back to zero once full and increases the number next to the level text block in the monsters BP add a new function bring in your variable from your current level progress since my max level progress is 10 I'm going to reset the bar when my current level progress is greater than 9. if I use 10 instead of 9 or use greater than or equal to instead of greater than my bar will stay full for one more additional click and I don't want that [Music] plug this condition into a branch and then if it's true we want to increase our level number by one and then reset our current level progress back to zero foreign [Music] node and switch back to your event graph [Music] [Music] add the newly created function to your event tick [Music] [Music] great our progress bar is resetting but our number isn't increasing this is because our level number variable for our monster is not connected to our UI so let's go ahead and do that back in your widget blueprint highlight the number that represents your Monster's level in the details panel select the bind drop down next to the text box and create a new binding this will create a new function for you which you can access in the widget blueprints graph once in the function get your monster using get actor of class drag out the level number variable and add that into the return node foreign [Music] awesome it's working as expected now for the fun part let's create the ability for our monster to evolve because my wolf cub mesh and my adult wolf mesh are similar in size I'm going to make my Monster's first form smaller by scaling it down to create the ability to evolve we'll be using a custom event instead of a function we will be using the do once node and when using that combined with our logic it does not work properly in the form of a function so right click in your event graph and add a custom event the first thing we need to check is if our monster is at the desired level for evolving [Music] bring in your level number and check if it's greater than or equal to the desired number in my case I'll use level one foreign if that's true we want to do another check to see if our monster is at the level for their final evolution using the same logic we just added I'll have my monster evolve into their final form at level 2. if our monster is Level 1 and ready to evolve into their second form this means their level is one or greater but not two or greater so let's drag out from the false pin of our second branch and search for do once I want to add a particle effect upon evolving so I'm going to jump over to my content browser and highlight the desired Niagara effect [Music] with the effect highlighted jump back to the event graph and search for add Niagara particle system component make sure it shows the name of the effect beneath the title of the node after that drag out and search for set skeletal mesh asset drag in your mesh from the components panel and plug it into the target slot since I made my initial mesh smaller I want to set the overall scale back to one using set world scale 3D and plug my mesh into the target as I mentioned before my first and second form used the same skeleton so I don't need to change the anim BP quite yet if your mesh uses a different skeleton you can switch its animation blueprint to the one you made earlier using the set anim instance class node search for your animation blueprint in the class drop down and plug in a reference to the mesh as the target [Music] for our Monster's final form we want to go back to our second Branch node and drag out from true this means our Monsters level is greater than or equal to 1 and greater than or equal to two same steps as before add the do once node and add the Niagara particle system as long as it's still highlighted in the content browser change the mesh in the anim instance class as before also [Music] one last thing we need to do is change the material you'll need to go back and do this for your second form if your monster uses a different material for that form drag out from the set anim instance class and search for set material plug in the reference to your mesh and locate the desired material in the drop down if you're having trouble finding the name of your material you can highlight it in the content browser and select it using the arrow next to the drop down in the node [Music] to call our new event we want to add to our tick event with a couple of conditions we only want to run the event if our Monster's level is equal to the exact level for evolving add a branch and bring in a reference to your level number if the number is equal to 1 I'm going to call the event if the number is not equal to 1 I'll check if it's equal to 2 and if so I'm going to call the event [Music] thank you [Music] and we're done everything appears to be working as expected and we're not getting any errors in the console foreign if you watched my AI animals video you can use the logic from that video to expand on this system this will allow Your Monster to run around and randomly perform various animations since this video is already long enough I'm not going to go into how to set up the logic but if you want to pause the video and try to set it up on your own it's not too challenging one thing you'll need to add is checking which mesh your monster is currently using in order to add the appropriate animation montages if you don't care about adding the montages you could simply add the first two nodes and your monsters should run around randomly no problem just don't forget to call your event in the begin play event and add a nav mesh to your level if you want to see more tutorials like this one drop a comment below or hit that subscribe button alright everybody thanks for watching I'll catch you later [Music]
Info
Channel: Elusive Panda
Views: 2,592
Rating: undefined out of 5
Keywords:
Id: fbfGa9ZTuOI
Channel Id: undefined
Length: 23min 26sec (1406 seconds)
Published: Sun Aug 13 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.