How to Make a Enemy Target Lock System 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 a very simple enemy Target lock system it's going to be very easy video to flow so let's get started but first check out the link in the description to get out with some unreal ending courses on winfox alright so the first thing that we're going to do is go ahead and open up our third person blueprint of course if you use any other blueprints you can use your own one so I'm gonna be making that when you press tab you basically enable this mode so find the Tab Key there we go so I'm gonna make it that when you press it you can add a flip-flop note which will mean that uh the first time it will do this and the second time of do this so we're going to create a new variable which is um Target lock and then we're gonna go ahead and set it to true on the A and on B is going to be set to files there you go so the next thing that we are going to do is create a sphere trace for object so oh basically detect all the objects that are around our player but in this case gonna be just the ones in front um so we can detect our enemies so the third position is going to be our get actor location and let me just make another space here so we'll start our location and the end point is going to be our camera get rotation get vote rotation and get the forward Vector so we will basically get the direction in which the camera is facing and then we're gonna multiply this value by a float which is going to be the distance that we will basically be able to Target lock so in my case let's do it like for example 500. now then we'll go ahead and add this and then Contour but in the second one and add it into our actual location this will be your end point and the red user can make it something as 150 25 sorry then I'm gonna make the object types so I'm gonna make an array so it will basically detect all the pawns as our enemies is going to be pawns normally and then guess I did the book time to uh for duration so we can preview how our Trace will look so if we're you know making it correctly we can literally test this so we can go ahead and press play and if we go here and press tab you will see that we're getting a sphere Trace in the direction where the camera is basically looking great so now let's keep going so we're gonna make the return value into branch so we'll just continue if we actually have detected our enemy then the out here we're gonna break it and then we'll get all the different things that we uh broadcasted into so we're gonna get the hit actor so we're gonna promote into value and it's going to be the target well the head Target basically I think it's a good name and then this will go into true over here so it will be a sign in there there we go the next thing that we are going to do is up here I'm going to add the um Advanced tick so in every frame we'll be doing one thing and we'll get the kit Target and then I'm gonna convert it into a validated kit so it will only continue if we are actually um basically uh detecting a enemy so what we're going to do is get our controller and then we're gonna say um set um control rotation it's gonna mean if it's valid and the thing is that the new rotation is going to be the uh look at find local rotation so we'll return our node and the start point is going to be our get actor location so where we are right now and then the target is going to be our hit Target location two so get actor location here we go go ahead and put this in Target and we can compile and say so the next thing that we're going to do is basically just put a simple enemy just 10 in there so we can log into now I'm gonna make it I'm not gonna make it like run around and stuff I have a tutorial on a very easy enemy AI system so if you want to check it out I will be leaving it in the description but anyway I'm just gonna make it so that there's an AI Sun there so let's create a new blueprint class and it's going to be type of um uh pawn and it's going to beep enemy now I'm gonna go ahead and open it up so I'm just gonna add a skeletal mesh with the many so it will be there and then basically uh rotate it minus 90 degrees here we go and then in the NM class you can add the many blueprint so it will basically be animating itself okay so now what we can do is just drag it into the scene and basically rotate it like that into 180 degrees so it will be facing us so if we go ahead and hit play you will see that if I go here and press tab um it will not still detect our player this is because there's Burly Coalition enabled on our enemy so we can go into skeleton mesh and we can start going down and you can see the Collision presets well it's not collation we don't want that we want to set a collision so it will be Pawn as you remember that in the third person connective blueprint in the trace we're looking for pawns objects so this is exactly what we want so if we now go ahead and click play and go here and there we go we can snap into our object and you can see that we are basically Target locking into that object now if you press tab again it would not do anything this because we haven't implemented the um skipping of the entire lock so when I'm here when we set it to false um that we are basically not using right now the target lock we will use it in a second but I'm gonna make it like that so we have more space and I'm gonna set the target lock to be and empty so basically we will lose our reference so it will not continue to continue on the tick okay so now if we press play we can go into our enemy sorry log into it but when I press tab again you'll see that we go back into um reality and basically I have just realized that we are not really using tired like Boolean uh I know that I just literally two seconds ago I mentioned that we'll do something about it but I just realized that uh because we are here controlling that is valid to get it uh we don't really need any um control about it so we can literally just go ahead and delete this and just plug it in directly into a over here and this into B and I guess it will even look a bit more cleaner so there we go and then um we can delete our variable yeah so a bit more um you know organized so I'll get quickly go ahead and select this press C to comment it and it's going to be the Target lock Trace and um hit and then this is going to be our set Target so Target lot rotation and it will end up being very very clean and there we go so that's it guys if you enjoyed the tutorial and found it helpful award update Collective video And subscribe to my channel I have lots of Unreal Engine 5 tutorials so this one um check out the link in the description for our some unreal ending courses and now yes well that's it bye bye foreign [Music]
Info
Channel: Gorka Games
Views: 32,965
Rating: undefined out of 5
Keywords: games, videojuegos, unreal engine, unreal engine 5, ue5, target lock, tutorial, quixel, megascans, unreal engine target lock, target lock unreal engine 5, ue5 target lock, ue5 enemy target lock tutorial, ue5 how to lock target on enemy, unreal engine 5 enemy lock on target system, unreal engine 5 target lock system, unreal engine 5 how to target lock the enemy, ue4, unreal engine 5 target lock enemy tutorial, ue5 lock on target tutorial, target lock system in ue5
Id: JNUSR_eM4OY
Channel Id: undefined
Length: 8min 12sec (492 seconds)
Published: Sat Nov 26 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.