How to Make the NPC's Head Look At the Player 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 and today I'm going to show you on how to make your NPC enemy or AI look at the player basically at you while you're playing the game it's gonna be a very easy route to follow so let's get started alright so first of all I don't have a you know an AI to be here in standing so I'm gonna go ahead and quickly just create once of course if you already have created your AI or enemy you can just skip this step but let's go ahead and create a new blueprint class this will be type character BP AI to look let's go ahead and just open this up and now what I come to do is put the mesh to be for example money all right there we go it's gonna be minus 89 and then minus 90 so it's looking perfectly great so now the thing that I have to do is create the the animation blueprint okay so if you of course if you have already created the animation blueprint and basically you can use uh open your animation bloop and the other one that you have so my case I have to go here animation blueprint and select the SK mannequin skeleton ABP underscore AI to look and let me open this up and for me I'm just gonna go ahead and place the idle animation that will go ahead and play in a loop animation great and now I can just go here and assign it great so now I guess that here is where really the tutorial starts so we have to do is go into the animation blueprint I'm going to go into the event graph so right over here in the update animation we're gonna go ahead and cast to the third person character and the object is going to be the get player uh character so we're basically accessing our player character and I want to do is go ahead and get the mesh let's go down and then here it is and then we want to get basically be a socket location and the second location will be head so it has to be exactly spelled like you have it so in my case I can just go here into this curtain and search for head and indeed it is written like this just in lowercase so it has to be exact the bone name and now what I'm going to do is right click and promote this to a bevel and this will be the look add pass this will be basically the position that the AI will look at which in a case will be the player's head so now we need to do is go into the ending graph and we have to right click and add this node which is called look at and now we can just make some space and plug it in you will see that it will create some notes which is we'll just go from local to component is totally fine it has to do that but it is great so you have to basically pretty much add it just before the output post so it will override any other animations so now what we have to do is Select it and then select the bone to modify which in our case we want to you know turn the head so it will be the head and then the last thing that we have to do is go into the look at location and then go ahead and expose this as the pin so now we can just go get our look at pause and just drag it in so now it will be assigned and we can leave the alpha at one so now you will see that if we compile and save and press play there we go the the enemy will be looking at this of course when we are in front of him it looks good but you know we want to go ahead and clamp his angle because we don't want to do you know what we're doing right now here which is just turning his head like if it's yeah we don't want that now so it's very uh on spot it is you know we want to smooth out a bit the he has movement so let's go back into the animation blueprint and let's select the lookout node and then what we need to do is go into the look at clamp and for example let's put 55 around 55 and then the interpolation time this is the uh basically time to smooth out a bit the vision turn so we can just put for example three so now you will see that when I press play you can see the now the AI will only be going ahead and turn his head to be looking at that 50 feet at 55 sorry angle and you can see it follows me great but when I'm behind him it is completely perfect click the normal and then he has a smooth turn so it looks a bit better when I jump it follows my head everything is working as strong so that's it guys if you found it so helpful I really appreciate you could like the video and subscribe to my channel I have lots of unview engine for tutorials as this one so if you want to go ahead and check them out go ahead during my Discord server and now yes with all I said bye bye foreign [Music]
Info
Channel: Gorka Games
Views: 40,226
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, npc look at player, tutorial, quixel, megascans, unreal engine head look at, eney look at player unreal engine 5, ue5 ai look at player, ue5 head look tutorial, ue5 how to make the npc look at you, unreal engine 5 npc look at player head, unreal engine 5 head look at, unreal engine 5 look at head, unreal engine 5 how to mesh look at head, unreal engine 5 head look, ue5 enemy look at player tutorial, npc head look in ue5
Id: 8skq8t_Fffk
Channel Id: undefined
Length: 4min 54sec (294 seconds)
Published: Tue Mar 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.