How to Tell AI to Move to Where the Player is Pointing in Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys welcome to new Unreal Engine 5 tutorial today I can show you how to tell your AI to go into a specific point that you're pointing at it's gonna be a very easy way to follow so let's get started alright so the first thing I want to do is go ahead and right click and create a blueprint class I'm going to create the AI itself so I'll go into the character BP underscore I don't know uh Target AI for example doesn't really matter let's go ahead and open this up so first of all we have to add some mesh into it so in my case I'm gonna put use for example money and then go simple let's put it into position so minus 89 over here and then minus 90. so it will be facing the correct way and then we can just go into here and search the money every Pizza will have some animations so great so with that we're going to go into the vein graph and delete all of this now go ahead and just create a new custom event which will basically be used and go to Target and basically this will contain an input that will pass through our player which will will be the Target location so basically where the AI will need to go and here we're going to put it as a vector because basically it's a position in the world all right so with that we can use oh use this node which is the AI move to this one over here and with that we can just pass the destination to be here and then the pawn will be itself because I mean that's the AI that is moving and the entire outer we can leave it empty and another set from Charities we need to put a little bit like five it will be okay and then a successful games do nothing because I will just wait there until we tell him to move into that point so that would be perfect okay so with that now of course we have to go ahead and make the basically the logic of the pointing and selecting the area that we want to go but before I make quickly just go ahead and drag the AI into the scene and let me just rotate it so it's looking as nice and clean okay and now the things that we have to add something in the scene so our AO AI will be able to move so if we just go up here and to quickly add to the part we can go into the volume section and add a nav mesh bounce volume and we can just go ahead and just make this big so you go into the scale lock it and just put like 50 something like that real beginner if we play SP and you will see that we have generated the the zones that our AI will be able to navigate through I already had enough Mass bounce volume but you know doesn't matter um okay I don't have any more okay from another tutorial but yeah you have to do that and there you go so with that said now we have to go into our third person character in order to add this functionality of pointing into a place so let's go into the third person character blueprint third person character blueprint and then let's go into bank graph into a nice place and I gotta do when we press the N key for example so let's go up here and find it there we go and then we're going to do is do a line Trace by Channel align Trace will be basically like an invisible Ray that will go from one point to another one in this case from our player's camera into the floor that we're pointing it so let's go and get the full camera and let's get the world location let's go ahead and put this over here so this will be the starting point but the end point will be both we need to get the um rotation the world rotation and then we need to get the forward Vector basically where the camera right now is looking at and then when we have that we can go ahead and multiply this by value this will be the distance that we want to be able to um shoot the ray so just right click over here and convert this into a float so it's a nice number I'm going to just put this as I don't know very Dodge number basically the distance that you will be able to uh point and make the AI go to my guess I'm going to make it real big it doesn't matter now let's get the what location add this with the other and forward Vector we can just plug that into the end position so now if we go here and set this into the debug type for duration we can preview it and if I just quickly press play and can press n and you can see we're doing if it doesn't crash there we go a point and basically saying hey go here go here go here go here and of course it makes sense that you pick a point in the ground because that you pick in the well the eye will not able to get here but you get a dead ass juice on the player Behavior right but this is working so let's go back here and uh we're going to do is make sure that we have hit something so if the turn value is true we can go ahead and get the out head and then break it basically this will contain all the parameters or an information of what we have had the location and stuff and we want is to get a location so in the truth we're gonna get the get actor of class okay and basically we want to find our BP Target that we have in the scene and from there we can call the um what was the move okay so we can use code the function that we created well the custom event and then just plug in the location into here and with that the AI should go ahead and move so we go ahead and press play you can see the AI is not moving but if I press n and look there uh nothing will happen and it's because it basically unloaded the Napa's uh bounce volume you can see if we don't have enough mesh the air would not be able to move and to resolve this just go and open again your map and which is the third person map in my case and I will be back if I press speed should appear this is just things of the world partition don't explain me why sometimes it just unloads things so if it doesn't move for you make sure you restart the scene and your nav mesh bones volume is there okay now yes if I press n look at point there we go it will go ahead and move into a point great of course it is very Snappy and there's no animations playing on either other than the idol so let's go ahead and fix those two things so quickly let's go into tutorial ai go into the um class defaults and search for jaw let's disable this so basically that was like a making the rotation very Snappy but now we go and select the character mode component go down down we can go into the use controller uh sorry Orient rotation to movement and it will basically run to the movement very smoothly that's what we want basically and now we want to quickly go ahead and create an uh pen space 1D okay and this will be basically the SK mannequin okay so going here this will be the target AI let's open this up okay and then we can spot the speed here okay so on the horizontal axis and the max to be I don't know 600 or whatever the AI had actually let's make it a bit uh kind of slower so we can select the character mode component go to Max walk speed and set it to 350 for example and then we can go here and put it in 350. and down here we can get the idle animation this case will be the the M because it was money I believe that I put it and then also the basically walk animation and basically walk forward and put it into the end so now if I hold Ctrl you can see that the speed increases will be transitioning between the uh animations uh so with that said okay now close this and quickly just right click animation blueprint and create a and one for the a SK mannequin again ABB underscore Target AI let's open this up and we are nearly finished just get the the one that we created for is the AI so type AI button space plug this into the output post and just right click enter the speed and then uh and promote survival so now in the band graph we can just get from the owner the current velocity that it has and we can use this node which is the vector length and if I know how to type length which we'll just compare this Vector into a nice float so again it's passed it into our speed so like this like this compile save and of course remember to go into the AI and actually go into the mesh and put in the one that we have to just create it because not it will not do anything and it was and what was Target AI yes and with that said everything should be nice so if I press play to go into this point it will turn nicely and go with walking animations really cool into that point and of course we can make it even smoother if we go into the blank space and first of all go into weight and put like for example 10 of weight and then uh you can see that's a bit better but then in the smoothing time for light 2.2 and so now yes that should be much smoother you can see yeah as much better as you can see now ai will go into the point that we go ahead and say and honestly come on it it looks really cool this is all right looking really cool as you can see and what we're gonna do is quickly go and just play a little sound so an AI you can just go right after and say play sound and add location this is okay whatever and plug in the location now we'll play a sound there um and then also we can do it's for like a quick particle there a sponge there right so we can just go and I think that if I have started content we have some particles here let me just check so yeah we have for example Sparks uh yeah that might not exactly work let's create our quickly our hyper system just right click and I resist them a new system your next of course you can skip this part but let's go into the and say Fountain now Fountain will be always working uh directional bars yeah it's a click the plus icon finish and then uh yeah okay leave the name like this it doesn't really matter and we can really just go into the this and just go to the because this country Ai and do a spawn a system add location and again it's passing the one that we have is created and then the location there and the rotation and stop looking instantly like this so now it should work but of course I mean we did not do any change into the particles but you get idea now it's parking as you can see the thing is that we have our character in the center so if I work quickly this is just an extra thing I need to do to be able to Showcase better the thing but I'm going to quickly just add an offset in the camera boom you don't have to do this just to me to Showcase better in the um socket offset I believe it is in here put it to 50 or something like that so be more to the side and now you can go and there you go you can see now this already looks pretty cool and of course I can get rid of the line traces um if I just go in here and getting the photoration off but I can just go ahead and put for duration to these like 0.7 seconds so it's really quick as you get a feedback so that's it guys if you found so helpful I would appreciate you like the video and subscribe to my channel so go ahead and take them out now yes what I said bye bye foreign [Music]
Info
Channel: Gorka Games
Views: 10,950
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5ai move to where the player is pointing, tutorial, quixel, megascans, unreal engine ai go to point, tell ai to go to point tutorial ue5, ue5 ai companion tutorial, ue5 ai go to point tutorial, how to tell the ai to go into a point in unreal, unreal engine 5 how to whistle ai
Id: K4t4rJLrUi4
Channel Id: undefined
Length: 11min 44sec (704 seconds)
Published: Fri May 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.