Unreal Engine 5 Tutorial - AI Part 1: Character Setup

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome to a refreshed revamped series using unreal engine 5 in ai in this series we'll be covering everything to do with ai in the ai systems in unreal engine in this first episode we're going to start off the basics of setting up an ai character including how to do the animation using the current new ue5 mannequins so let's get started so we're going to start off by creating our character class now in our characters folder which is part of the third person template you can go in here and create another folder for our ai and in here we're going to create a new open class and choose a new character class this is going to be our npc class the bp npc alongside that we also need to add in the ai controller so go into different class again search for all classes i'm going to search for the ai controller the ai controller is what is going to be controlling our ai character around the level so we have this i'm going to call it ai or npc next i'm going to do is going to go into our bp and pc and open up our character and set her up to use the many mannequin mesh component on the right hand side we're going to choose animation uh let's go sorry skeletal mesh here and choose the skm many bring that down into the capsule and turn it around face the right way now this mannequin does come with a animation blueprint which you can find here here apb many however there's an issue with this one in that this animation blueprint does use something that requires a player input so if you try to make anything like ai use it it won't work so we have to edit our apb menu to make it work for our player character and via ai i'm going to click on the browse icon to get to the appb many blueprint here this only applies if you're using this mannequin's animation blueprint if you're using your own one totally up to you you can achieve that so the culprit for that you'll find in here is down in this section here update animation in then one is this get current acceleration now as you can see from the tooltip this requires input from the uh movement component but a player input level now we don't necessarily have player input because this could be for ai as well but there's a way around this we can either skip this entirely and just make this work we should move or if we also want to take that into account as well is we want to do a check to see if the pawn is player controlled so let's move that down a little bit here right click and do try get on owner and there we're gonna do this player controlled and if it is player controlled we're using this branch here so it should move we're going to take this down and do select select so and the index is going to be our is player controlled it's true we'll be using this stuff that was here previously if it's false we're only going to be using the ground speed also going into there and that will fix that for us to work for both the player and for ai i'm going to go back to my mpc and mpc blueprint and should see it should look just fine now if you go to the class defaults in a c section for ai controller in here you've got two options to you need a tweak and change you've got ai controller class so this is the by default set to the uh the default ai controller class that's been given in unreal we're going to change this to our custom one we made ai npc then the other option you may want to change is this auto process ai depending on what your setup is you may require your ai to be placed in the world and be and be processed straight away maybe you want them to be possessed only when they've been spawned into the world or both maybe or disabled entirely as well but there's a few options you can do there we'll keep it placed in world for now but just so you know that's the thing okay we're done here gonna compile and save this and we're gonna close that the other thing we're gonna need in our map is a navigational mesh now never meshes are found in your add option menu you go down to volumes and it's right at the top nav mesh bound volume i've already added it to the level and stretch it across the whole entire level and just preview it you hit the p key you'll see that green nav mesh indicating where the npc could go the dark green outlines are borders meaning that it cannot cross the border unless connected by a nav link proxy or by another navigational mesh but reminder toggle that often on with the p key okay so now we've got our ai character itself we'll drag it into the scene uh but now we need to give it some behavior to run around now we're going to do something very basic we'll make him just follow the player character i'm going to go to my content drawer open up the character here and on begin play we're going to do a i move to and i moved him this requires a pawn reference was itself and the target act we're going to give it is the get player character that is it i'll save and i'll push play now now you can see he's going to run after me so a few other things we want to do with our ai is we want to make sure they can turn properly when you first create a character you'll find the turning looks a bit weird it looks very like very uh abrupt very strange so we're going to fix that which go open up our mp npc and go to class defaults and on the right side you'll see an option saying use controller rotation your you want to turn this off you mostly only want this on when you're doing first person controls as you want the control rotation to be manipulated by the character movement component so speaking of which click on the catch movement component and then scroll down on the right hand side until you find the rotation settings they are and we're gonna tick use controller desired rotation whilst i'm here i'm also going to tell it to go a bit slower so you'll find max walk speed down to like 350. so back on those rotation settings you will find the two tick boxes use controller desired rotation and orient rotation to movement uh these basically mean that the controller desired rotation is the controller wants it to go in a particular way therefore it will turn the whole character model around to match that direction whereas character movement orient rotation movement means if the character is moving a certain direction it will look in a direction that is currently moving in so your camera could be facing one way for example and you character could be running the door but for this for ai we wanted to use controller design rotation the rotation rate just means it can turn 360 degrees in one second so could it turn slower make it lower quicker make it higher okay now if i push play you can see him now coming after us and that brings us to the end of part one now we've got a basic character set up we're going to start we're looking at the behavior tree system so the next episode we're going to go through the behavior tree explaining the different functions it has and how we can use it to move the character around the space and watch our next episode right now over on patreon.com forward slash ryan laylee as well as many other videos too from just one dollar a month i said thank you to all my patrons and youtube members for the continued support please make sure you subscribe to the channel and i'll see you next time bye everyone [Music] you
Info
Channel: Ryan Laley
Views: 139,446
Rating: undefined out of 5
Keywords:
Id: IDZh0epFTRY
Channel Id: undefined
Length: 9min 16sec (556 seconds)
Published: Fri Aug 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.